diff options
Diffstat (limited to 'skills/python/SKILL.md')
| -rw-r--r-- | skills/python/SKILL.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/skills/python/SKILL.md b/skills/python/SKILL.md new file mode 100644 index 0000000..966a4fd --- /dev/null +++ b/skills/python/SKILL.md @@ -0,0 +1,30 @@ +--- +name: python +description: Pythonコードを作成・実行・検証する。計算、データ処理、自動化、CLI、試作、デバッグ、またはPython testを求められたときに使用する。 +--- + +# Python + +## Workflow + +1. 目的、入出力、作業directory、Python version、完了条件を確認する。 +2. 既存projectでは関連fileを先に読み、新規作成では標準ライブラリで満たせるか確認する。 +3. 複雑なコードは許可された作業directory内の`.py`へ保存する。`python -c`へ長いコードを埋め込まない。 + - 小さな修正で`file_edit`の`patch` operationを使う場合、`patch` fieldにはJSON文字列`{"old_text":"置換前","new_text":"置換後"}`を渡す。unified diffや`@@`形式を渡さない。置換前文字列はfile内で正確に1回だけ一致させる。 +4. 承認済みのPython executableを直接`process_run`し、cwdとargsを分ける。shell、launcher、環境探索Toolを経由しない。 +5. 通常のscriptは`-I <script>`で実行する。単一test scriptは`unittest.main()`を持たせて`-I <test-script>`で実行するか、`-I -m unittest discover -s <test-directory> -p <pattern> -v`で明示的に探索する。isolated modeでimport不能になるfile pathを`-m unittest`へ直接渡さない。 +6. test codeでも`subprocess`、`multiprocessing`、`os.system`を使用しない。CLIはentry functionへ引数とI/Oを渡し、同一process内で検証する。 +7. 正常系に加え、重要な境界条件と失敗条件を決定的なtestで確認する。 +8. stdout、stderr、exit codeを確認し、exit code 0と期待結果の両方を満たした場合だけ成功と報告する。 + +## Dependency Rules + +- 標準ライブラリを優先する。 +- dependencyが不足していても、依頼なしにnetwork接続やpackage installを行わない。 +- 外部packageが必要な場合は、package名、理由、必要な許可をユーザーへ示す。 + +## Safety and Reporting + +- Python executableまたは作業directoryの権限が不足している場合は迂回しない。 +- descendant processを生成するコードや、依頼されていないfilesystem/network操作を追加しない。 +- 最終応答では作成・変更したfile、実行したtest、exit code、主要結果、未検証事項を簡潔に示す。 |
