├── docs └── .gitkeep ├── src └── project_name │ ├── py.typed │ ├── core │ ├── __init__.py │ └── example.py │ ├── utils │ ├── __init__.py │ ├── helpers.py │ └── logging_config.py │ ├── __init__.py │ └── types.py ├── template ├── tests │ ├── unit │ │ ├── __init__.py │ │ ├── test_example.py │ │ ├── test_logging.py │ │ └── test_helpers.py │ ├── integration │ │ ├── __init__.py │ │ └── test_example.py │ ├── property │ │ ├── __init__.py │ │ └── test_helpers_property.py │ └── conftest.py └── src │ └── template_package │ ├── py.typed │ ├── core │ ├── __init__.py │ └── example.py │ ├── __init__.py │ ├── utils │ ├── __init__.py │ ├── helpers.py │ ├── logging_config.py │ └── profiling.py │ └── types.py ├── tests ├── __init__.py ├── unit │ └── __init__.py ├── integration │ └── __init__.py ├── property │ └── __init__.py └── test_dummy.py ├── .gemini └── settings.json ├── assets └── 和太鼓でドドン.mp3 ├── .claude ├── commands │ ├── gemini-search.md │ ├── initialize-project.md │ ├── gemini-documentation.md │ ├── index.md │ ├── ensure-quality.md │ ├── analyze.md │ ├── write-tests.md │ ├── commit-and-pr.md │ ├── improve.md │ ├── task.md │ ├── safe-refactor.md │ ├── troubleshoot.md │ └── scan.md └── settings.json ├── .gitignore ├── .github ├── dependabot.yml ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── feature_request.yml │ └── claude_code_collaboration.yml └── workflows │ └── ci.yml ├── LICENSE ├── .pre-commit-config.yaml ├── pyproject.toml ├── scripts ├── update_project_name.py └── setup.sh ├── Makefile └── CLAUDE.md /docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/project_name/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/tests/unit/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/src/template_package/py.typed: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /template/tests/integration/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | """Test package.""" 2 | -------------------------------------------------------------------------------- /tests/unit/__init__.py: -------------------------------------------------------------------------------- 1 | """Unit tests.""" 2 | -------------------------------------------------------------------------------- /tests/integration/__init__.py: -------------------------------------------------------------------------------- 1 | """Integration tests.""" 2 | -------------------------------------------------------------------------------- /tests/property/__init__.py: -------------------------------------------------------------------------------- 1 | """Property-based tests.""" 2 | -------------------------------------------------------------------------------- /.gemini/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "contextFileName": "CLAUDE.md" 3 | } 4 | -------------------------------------------------------------------------------- /template/tests/property/__init__.py: -------------------------------------------------------------------------------- 1 | """Property-based testing module.""" 2 | -------------------------------------------------------------------------------- /src/project_name/core/__init__.py: -------------------------------------------------------------------------------- 1 | """Core module for project_name package.""" 2 | -------------------------------------------------------------------------------- /src/project_name/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """Utilities module for project_name package.""" 2 | -------------------------------------------------------------------------------- /assets/和太鼓でドドン.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/discus0434/python-template-for-claude-code/HEAD/assets/和太鼓でドドン.mp3 -------------------------------------------------------------------------------- /tests/test_dummy.py: -------------------------------------------------------------------------------- 1 | """Dummy test for template repository CI.""" 2 | 3 | 4 | def test_dummy(): 5 | """Dummy test to make CI pass in template repository.""" 6 | assert True 7 | -------------------------------------------------------------------------------- /template/src/template_package/core/__init__.py: -------------------------------------------------------------------------------- 1 | """Core functionality of the package.""" 2 | 3 | from .example import ExampleClass, ExampleConfig, process_data 4 | 5 | __all__ = [ 6 | "ExampleClass", 7 | "ExampleConfig", 8 | "process_data", 9 | ] 10 | -------------------------------------------------------------------------------- /.claude/commands/gemini-search.md: -------------------------------------------------------------------------------- 1 | ## Gemini Search 2 | 3 | `gemini` is Google Gemini CLI. You can use it for web search. 4 | 5 | Run web search via Task Tool with `gemini --yolo -p 'WebSearch: ...'`. 6 | 7 | ```bash 8 | gemini --yolo -p "WebSearch: ..." 9 | ``` 10 | -------------------------------------------------------------------------------- /template/src/template_package/__init__.py: -------------------------------------------------------------------------------- 1 | from .core.example import ExampleClass, ExampleConfig, process_data 2 | from .utils.logging_config import get_logger, set_log_level, setup_logging 3 | 4 | __all__ = [ 5 | "ExampleClass", 6 | "ExampleConfig", 7 | "get_logger", 8 | "process_data", 9 | "set_log_level", 10 | "setup_logging", 11 | ] 12 | -------------------------------------------------------------------------------- /src/project_name/__init__.py: -------------------------------------------------------------------------------- 1 | from .core.example import ExampleClass, ExampleConfig, process_data 2 | from .utils.logging_config import get_logger, set_log_level, setup_logging 3 | 4 | __all__ = [ 5 | "ExampleClass", 6 | "ExampleConfig", 7 | "get_logger", 8 | "process_data", 9 | "set_log_level", 10 | "setup_logging", 11 | ] 12 | 13 | __version__ = "0.1.0" 14 | -------------------------------------------------------------------------------- /.claude/commands/initialize-project.md: -------------------------------------------------------------------------------- 1 | # プロジェクトの初期化 2 | 3 | テンプレートリポジトリの初期化を行います。以下のTODOに従って作業を進めてください。 4 | 5 | - [ ] プロジェクトの概要がユーザーから提供されていない場合、ユーザーにプロジェクトの概要について質問を行う。ユーザー体験の観点から、一問一答で質問することが推奨されます。 6 | - [ ] `CLAUDE.md`の「プロジェクト概要」セクションをプロジェクトに特化したものに更新し、既存の記述を削除する。 7 | - [ ] `CLAUDE.md`の「詳細ガイドの参照」セクションをプロジェクトに特化したものに更新し、既存の記述を削除する。 8 | - [ ] `pyproject.toml`の`dependencies`セクションを更新する。 9 | - [ ] `tests/`ディレクトリにあるダミーのテストコードを削除する。 10 | -------------------------------------------------------------------------------- /template/src/template_package/utils/__init__.py: -------------------------------------------------------------------------------- 1 | """Utility functions for the package.""" 2 | 3 | from .helpers import chunk_list, flatten_dict, load_json_file, save_json_file 4 | from .logging_config import get_logger, set_log_level, setup_logging 5 | 6 | __all__ = [ 7 | "chunk_list", 8 | "flatten_dict", 9 | "get_logger", 10 | "load_json_file", 11 | "save_json_file", 12 | "set_log_level", 13 | "setup_logging", 14 | ] 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Python 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | *.so 6 | .Python 7 | *.egg-info/ 8 | dist/ 9 | build/ 10 | .eggs/ 11 | *.egg 12 | .python-version 13 | 14 | # Virtual Environment 15 | .venv/ 16 | venv/ 17 | ENV/ 18 | env/ 19 | 20 | # IDE 21 | .vscode/ 22 | .idea/ 23 | *.swp 24 | *.swo 25 | *~ 26 | .DS_Store 27 | 28 | # Testing 29 | .coverage 30 | .pytest_cache/ 31 | htmlcov/ 32 | .mypy_cache/ 33 | .ruff_cache/ 34 | test-results.xml 35 | coverage.xml 36 | .tox/ 37 | .hypothesis/ 38 | 39 | # Local 40 | .env 41 | .env.local 42 | *.log 43 | 44 | # Documentation 45 | .sphinx/ 46 | 47 | # Project specific 48 | .secrets.baseline 49 | -------------------------------------------------------------------------------- /.claude/commands/gemini-documentation.md: -------------------------------------------------------------------------------- 1 | ## Gemini Documentation 2 | 3 | `gemini` is Google Gemini CLI. Gemini excels in writing, so you should use it for documentation, or proofreading. 4 | 5 | Run `gemini` via Task Tool with `gemini --yolo -p '...(instruction)...'`. 6 | 7 | The more you describe the instruction in detail, the better. If you ask Gemini to write or update a document rather than proofreading, you should provide a comprehensive background information like what is written in `CLAUDE.md` or `README.md`. 8 | 9 | Documentation or proofreading is done automatically by Gemini. 10 | 11 | ```bash 12 | gemini --yolo -p "...(instruction)..." 13 | ``` 14 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | # Python dependencies 4 | - package-ecosystem: "pip" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" 8 | day: "monday" 9 | time: "00:00" 10 | open-pull-requests-limit: 10 11 | labels: 12 | - "dependencies" 13 | - "python" 14 | commit-message: 15 | prefix: "chore" 16 | include: "scope" 17 | pull-request-branch-name: 18 | separator: "-" 19 | 20 | # GitHub Actions 21 | - package-ecosystem: "github-actions" 22 | directory: "/" 23 | schedule: 24 | interval: "weekly" 25 | day: "monday" 26 | time: "00:00" 27 | open-pull-requests-limit: 5 28 | labels: 29 | - "dependencies" 30 | - "github-actions" 31 | commit-message: 32 | prefix: "ci" 33 | include: "scope" 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Verb 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.claude/commands/index.md: -------------------------------------------------------------------------------- 1 | # SuperClaude コマンドリファレンス 2 | 3 | このディレクトリには、Pythonプロジェクト開発を効率化するためのカスタムスラッシュコマンドが定義されています。 4 | 5 | ## コマンドカテゴリ 6 | 7 | ### 分析・改善 8 | - `/analyze` - 多次元コード分析(品質、セキュリティ、パフォーマンス) 9 | - `/improve` - エビデンスベースの改善提案と実装 10 | - `/scan` - セキュリティと品質の包括的検証 11 | 12 | ### 開発・デバッグ 13 | - `/troubleshoot` - 体系的なデバッグとトラブルシューティング 14 | - `/task` - 複雑なタスクの管理とトラッキング 15 | 16 | ## 基本的な使用方法 17 | 18 | ```bash 19 | # コード品質の分析 20 | /analyze --code 21 | 22 | # パフォーマンスの改善 23 | /improve --perf --iterate 24 | 25 | # セキュリティスキャン 26 | /scan --security --owasp 27 | 28 | # タスクの作成と管理 29 | /task:create "新機能の実装" 30 | ``` 31 | 32 | ## 既存ツールとの連携 33 | 34 | これらのコマンドは、プロジェクトの既存ツールと連携して動作します: 35 | 36 | - `make format/lint/typecheck` - コード品質チェック 37 | - `make test` - テスト実行 38 | - `make security/audit` - セキュリティ検証 39 | - `uv` - パッケージ管理 40 | - `gh` - GitHub操作 41 | 42 | ## 効率的なワークフロー 43 | 44 | ### 新機能開発 45 | ```bash 46 | /task:create "機能名" → /analyze → 実装 → /improve → /scan --validate → make test 47 | ``` 48 | 49 | ### バグ修正 50 | ```bash 51 | /troubleshoot --fix → /analyze --code → 修正 → make test → /scan --validate 52 | ``` 53 | 54 | ### パフォーマンス最適化 55 | ```bash 56 | /analyze --perf → /improve --perf --iterate → make benchmark → /scan --validate 57 | ``` 58 | 59 | ## 記号体系 60 | 61 | 効率的なコミュニケーションのための記号: 62 | 63 | - `→` : 処理の流れ 64 | - `|` : 選択・区切り 65 | - `&` : 結合・並列 66 | - `:` : 定義 67 | - `»` : シーケンス 68 | - `@` : 場所・参照 69 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## 概要 2 | 3 | 4 | ## 変更内容 5 | 6 | - 7 | - 8 | - 9 | 10 | ## 変更の種類 11 | 12 | - [ ] 🐛 バグ修正 (Bug fix) 13 | - [ ] ✨ 新機能 (New feature) 14 | - [ ] 💥 破壊的変更 (Breaking change) 15 | - [ ] 📝 ドキュメント (Documentation) 16 | - [ ] ♻️ リファクタリング (Refactoring) 17 | - [ ] 🎨 スタイル修正 (Style) 18 | - [ ] 🚀 パフォーマンス改善 (Performance) 19 | - [ ] ✅ テスト (Test) 20 | - [ ] 🔧 設定変更 (Configuration) 21 | - [ ] ⬆️ 依存関係更新 (Dependencies) 22 | 23 | ## チェックリスト 24 | 25 | ### コード品質 26 | - [ ] コードが正しくフォーマットされている (`uv run ruff format .`) 27 | - [ ] リンターのチェックをパスしている (`uv run ruff check .`) 28 | - [ ] 型チェックをパスしている (`uv run mypy src/ --strict`) 29 | - [ ] すべてのテストがパスしている (`uv run pytest`) 30 | - [ ] pre-commitフックが正常に動作する (`uv run pre-commit run --all-files`) 31 | 32 | ### 開発・ドキュメント 33 | - [ ] 新機能/修正に対するテストを追加した 34 | - [ ] ドキュメントを更新した(必要な場合) 35 | - [ ] CLAUDE.mdに新しいパターンを追加した(必要な場合) 36 | - [ ] CHANGELOG.mdを更新した(該当する場合) 37 | 38 | ### Claude Code協働 39 | - [ ] Claude Codeとの協働で作成された場合、適切なコミットメッセージを使用 40 | - [ ] 新しいコーディングパターンがCLAUDE.mdに反映されている 41 | - [ ] 複雑な実装に対して適切なコメントを追加した 42 | 43 | ## テスト 44 | 45 | 46 | ## スクリーンショット 47 | 48 | 49 | ## 関連Issue 50 | 51 | Closes # 52 | 53 | ## その他 54 | 55 | -------------------------------------------------------------------------------- /.claude/commands/ensure-quality.md: -------------------------------------------------------------------------------- 1 | # コード品質の自動改善 2 | 3 | `make check-all`が成功するまで、自動的にコードを修正してコード品質を保証します。 4 | 5 | このコマンドは、CLAUDE.mdの「コード品質を保証する」セクションに従い、以下の順序で品質チェックと修正を実行します: 6 | 7 | 1. **コードフォーマット** (`make format`) - Ruffによる自動フォーマット 8 | 2. **リントチェック** (`make lint`) - Ruffによるリントチェックと自動修正 9 | 3. **型チェック** (`make typecheck`) - mypyによる厳格な型チェック 10 | 4. **テスト実行** (`make test`) - 全テストの実行 11 | 12 | ## 実行手順 13 | 14 | 1. まず `make check-all` を実行して現在の状態を確認 15 | 2. エラーが発生した場合、以下の優先順位で修正を試みる: 16 | - フォーマットエラー: `make format` で自動修正 17 | - リントエラー: `make lint` で自動修正可能なものは修正、手動修正が必要なものは詳細を報告 18 | - 型エラー: エラーメッセージを分析し、適切な型ヒントや型キャストを追加 19 | - テスト失敗: 失敗原因を特定し、コードまたはテストを修正 20 | 21 | 3. 各修正後に `make check-all` を再実行し、すべてのチェックが通るまで繰り返す 22 | 23 | ## 重要な注意事項 24 | 25 | - **CLAUDE.mdの規約に従う**: 型ヒント、エラーメッセージ、コーディングスタイルはCLAUDE.mdの規約に準拠 26 | - **既存の動作を保持**: テストが失敗した場合、まず実装が仕様通りかを確認し、必要に応じてテストも修正 27 | - **段階的な修正**: 一度にすべてを修正せず、エラーの種類ごとに段階的に対処 28 | - **進捗の報告**: 各ステップでの修正内容と結果を明確に報告 29 | 30 | ## エラー対処の具体例 31 | 32 | ### 型エラーの例 33 | ```python 34 | # エラー: Incompatible return value type (got "None", expected "str") 35 | def get_name() -> str: 36 | return None # 修正前 37 | 38 | # 修正後 39 | def get_name() -> str | None: 40 | return None 41 | ``` 42 | 43 | ### リントエラーの例 44 | ```python 45 | # エラー: F401 'os' imported but unused 46 | import os # 修正: 未使用のインポートを削除 47 | 48 | # エラー: E501 line too long (120 > 100 characters) 49 | # 修正: 長い行を適切に改行 50 | ``` 51 | 52 | このコマンドを実行することで、プロジェクトのコード品質を一貫して高いレベルに保つことができます。 53 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | # Standard hooks 3 | - repo: https://github.com/pre-commit/pre-commit-hooks 4 | rev: v5.0.0 5 | hooks: 6 | - id: trailing-whitespace 7 | - id: end-of-file-fixer 8 | - id: check-yaml 9 | - id: check-toml 10 | - id: check-json 11 | - id: check-added-large-files 12 | - id: check-merge-conflict 13 | - id: debug-statements 14 | 15 | # Python formatting and linting 16 | - repo: https://github.com/astral-sh/ruff-pre-commit 17 | rev: v0.6.0 18 | hooks: 19 | - id: ruff 20 | args: [--fix, --exit-non-zero-on-fix, --config=pyproject.toml] 21 | - id: ruff-format 22 | 23 | # Type checking 24 | - repo: local 25 | hooks: 26 | - id: pyright 27 | name: pyright 28 | entry: uv run pyright 29 | language: system 30 | files: ^src/ 31 | types: [python] 32 | 33 | # Security 34 | - repo: https://github.com/PyCQA/bandit 35 | rev: 1.7.9 36 | hooks: 37 | - id: bandit 38 | args: [-c, pyproject.toml] 39 | additional_dependencies: ["bandit[toml]"] 40 | 41 | # Dependency vulnerability scanning 42 | - repo: https://github.com/pypa/pip-audit 43 | rev: v2.7.3 44 | hooks: 45 | - id: pip-audit 46 | args: [--desc, --fix] 47 | 48 | # Secret detection (optional - uncomment if needed) 49 | # - repo: https://github.com/Yelp/detect-secrets 50 | # rev: v1.5.0 51 | # hooks: 52 | # - id: detect-secrets 53 | # args: [--baseline, .secrets.baseline] 54 | -------------------------------------------------------------------------------- /.claude/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "permissions": { 3 | "allow": [ 4 | "Bash(claude --version)", 5 | "Bash(claude doctor)", 6 | "Bash(grep:*)", 7 | "Bash(find:*)", 8 | "Bash(ls:*)" 9 | ], 10 | "deny": [ 11 | "Bash(rm -rf:*)", 12 | "Bash(rm -fr:*)", 13 | "Bash(rm -fR:*)", 14 | "Bash(rm -Rf:*)", 15 | "Bash(sudo rm -rf:*)", 16 | "Bash(sudo rm -fr:*)", 17 | "Bash(sudo rm -fR:*)", 18 | "Bash(sudo rm -Rf:*)", 19 | "Bash(mv /* /dev/null)", 20 | "Bash(mv ~ /dev/null)", 21 | "Bash(python -c 'import os; os.system(\"rm -rf /\")')", 22 | "Bash(perl -e 'unlink glob \"/*\"')", 23 | "Bash(find / -delete)", 24 | "Bash(find ~ -delete)", 25 | "Bash(find . -delete)", 26 | "Bash(find / -exec rm -rf {} \\;)", 27 | "Bash(find ~ -exec rm -rf {} \\;)", 28 | "Bash(find / -exec rm {} \\;)", 29 | "Bash(find ~ -exec rm {} \\;)", 30 | "Bash(shred -vfz /dev/sda)", 31 | "Bash(shred -vfz /dev/sdb)", 32 | "Bash(cat /dev/urandom > /dev/mem)", 33 | "Bash(yes | rm -rf /)", 34 | "Bash(yes | rm -rf ~)", 35 | "Bash(kill -9 -1)", 36 | "Bash(killall -9 *)", 37 | "Bash(pkill -9 -f .)", 38 | "Bash(shutdown -h now)", 39 | "Bash(shutdown -r now)", 40 | "Bash(poweroff)", 41 | "Bash(reboot)", 42 | "Bash(halt)", 43 | "Bash(systemctl poweroff)", 44 | "Bash(systemctl reboot)", 45 | "Bash(systemctl halt)", 46 | "Bash(crontab -r)", 47 | "Bash(format c:)", 48 | "Bash(format /)" 49 | ] 50 | }, 51 | "hooks": { 52 | "Stop": [ 53 | { 54 | "matcher": "", 55 | "hooks": [ 56 | { 57 | "type": "command", 58 | "command": "play assets/和太鼓でドドン.mp3" 59 | } 60 | ] 61 | } 62 | ] 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /.claude/commands/analyze.md: -------------------------------------------------------------------------------- 1 | # /analyze - 多次元コード分析 2 | 3 | **目的**: コード、アーキテクチャ、セキュリティ、パフォーマンスの包括的な分析 4 | 5 | ## 概要 6 | 7 | `/analyze`コマンドは、Pythonプロジェクトの様々な側面を分析し、エビデンスベースの改善提案を提供します。 8 | 9 | ## 使用方法 10 | 11 | ```bash 12 | /analyze [オプション] [対象] 13 | ``` 14 | 15 | ## オプション 16 | 17 | ### --code 18 | コード品質の分析を実行: 19 | - 命名規則の一貫性 20 | - 関数・クラスの複雑性(サイクロマティック複雑性) 21 | - DRY原則の遵守状況 22 | - 型ヒントのカバレッジ 23 | - docstringの品質 24 | 25 | ### --arch 26 | アーキテクチャの分析: 27 | - レイヤー間の結合度 28 | - 依存関係の方向性 29 | - 設計パターンの適用状況 30 | - モジュール間の責務分離 31 | - スケーラビリティの評価 32 | 33 | ### --security 34 | セキュリティ監査: 35 | - OWASP Top 10の脆弱性チェック 36 | - 認証・認可の実装確認 37 | - 入力検証とサニタイゼーション 38 | - 暗号化とデータ保護 39 | - エラーハンドリングの安全性 40 | 41 | ### --perf 42 | パフォーマンス分析: 43 | - アルゴリズムの時間計算量 44 | - メモリ使用効率 45 | - I/O操作の最適化機会 46 | - データベースクエリの効率性 47 | - キャッシング機会の特定 48 | 49 | ### 分析深度フラグ 50 | - `--think`: 標準的な分析(デフォルト) 51 | - `--think-hard`: 深い分析 52 | - `--ultrathink`: 最も詳細な分析 53 | 54 | ## 実行例 55 | 56 | ### 基本的な使用 57 | ```bash 58 | # カレントディレクトリのコード品質分析 59 | /analyze --code 60 | 61 | # 特定ファイルのセキュリティ監査 62 | /analyze --security src/auth/ 63 | 64 | # 全体的なアーキテクチャ分析 65 | /analyze --arch --think-hard 66 | ``` 67 | 68 | ### 複合分析 69 | ```bash 70 | # コードとセキュリティの包括的分析 71 | /analyze --code --security --think-hard 72 | 73 | # パフォーマンスボトルネックの特定 74 | /analyze --perf --ultrathink src/core/ 75 | ``` 76 | 77 | ## 出力形式 78 | 79 | 分析結果は以下の形式で提供されます: 80 | 81 | ```yaml 82 | 分析サマリー: 83 | 対象: [分析対象のパス] 84 | 実行時間: [分析にかかった時間] 85 | 86 | 発見事項: 87 | 重大度: CRITICAL|HIGH|MEDIUM|LOW 88 | カテゴリ: [問題のカテゴリ] 89 | 場所: [ファイル:行番号] 90 | 説明: [問題の詳細] 91 | 証拠: [メトリクスや具体例] 92 | 推奨対応: [改善案] 93 | 94 | メトリクス: 95 | コード品質スコア: [0-100] 96 | セキュリティスコア: [0-100] 97 | パフォーマンススコア: [0-100] 98 | テストカバレッジ: [パーセンテージ] 99 | ``` 100 | 101 | ## 既存ツールとの連携 102 | 103 | `/analyze`は以下のツールと連携して動作します: 104 | 105 | - `mypy`: 型チェックの結果を統合 106 | - `ruff`: リンター出力を分析に含める 107 | - `bandit`: セキュリティ問題の検出 108 | - `pytest`: テストカバレッジの確認 109 | 110 | ## 注意事項 111 | 112 | - 大規模なコードベースでは`--ultrathink`の使用に時間がかかる場合があります 113 | - セキュリティ分析は補完的なツールとして使用し、専門的なセキュリティ監査の代替にはなりません 114 | - パフォーマンス分析は静的解析に基づくため、実際のベンチマークと併用してください 115 | -------------------------------------------------------------------------------- /.claude/commands/write-tests.md: -------------------------------------------------------------------------------- 1 | # t-wada流TDDによるテスト作成 2 | 3 | CLAUDE.mdの「テスト戦略」セクションで定義されているt-wada流のテスト駆動開発(TDD)に従って、高品質なテストを作成します。 4 | 5 | ## TDDの基本サイクル 6 | 7 | 1. 🔴 **Red**: 失敗するテストを書く 8 | 2. 🟢 **Green**: テストを通す最小限の実装 9 | 3. 🔵 **Refactor**: リファクタリング 10 | 11 | ## 実行手順 12 | 13 | ### 1. TODOリストの作成 14 | 実装したい機能をリストアップし、最小単位に分解します: 15 | ``` 16 | [ ] 基本的な機能の動作確認 17 | [ ] エッジケースの処理 18 | [ ] エラーハンドリング 19 | [ ] パフォーマンスが重要な場合はベンチマーク 20 | ``` 21 | 22 | ### 2. テストファイルの配置 23 | ``` 24 | tests/ 25 | ├── unit/ # 単体テスト 26 | ├── property/ # プロパティベーステスト(Hypothesis使用) 27 | ├── integration/ # 統合テスト 28 | └── conftest.py # pytestフィクスチャ 29 | ``` 30 | 31 | ### 3. テストの命名規則 32 | 日本語で意図を明確に表現します: 33 | ```python 34 | def test_正常系_有効なデータで処理成功(): 35 | """chunk_listが正しくチャンク化できることを確認。""" 36 | 37 | def test_異常系_不正なサイズでValueError(): 38 | """チャンクサイズが0以下の場合、ValueErrorが発生することを確認。""" 39 | 40 | def test_エッジケース_空リストで空結果(): 41 | """空のリストをチャンク化すると空の結果が返されることを確認。""" 42 | ``` 43 | 44 | ### 4. templateディレクトリの参考例 45 | 46 | **単体テスト** (@template/tests/unit/test_example.py) 47 | - 関数・クラスの基本動作 48 | - 正常系・異常系・エッジケース 49 | - パラメトライズテストの活用 50 | 51 | **プロパティベーステスト** (@template/tests/property/test_helpers_property.py) 52 | - Hypothesisによる自動テストケース生成 53 | - 不変条件の検証 54 | - エッジケースの自動発見 55 | 56 | **統合テスト** (@template/tests/integration/test_example.py) 57 | - コンポーネント間の連携 58 | - ファイルI/Oやデータ処理パイプライン 59 | - エラーのカスケード処理 60 | 61 | ## 三角測量の実践例 62 | 63 | ```python 64 | # Step 1: 最初のテスト(仮実装で通す) 65 | def test_add_正の数(): 66 | assert add(2, 3) == 5 67 | 68 | def add(a, b): 69 | return 5 # 仮実装 70 | 71 | # Step 2: 2つ目のテスト(一般化を促す) 72 | def test_add_別の正の数(): 73 | assert add(1, 4) == 5 74 | assert add(10, 20) == 30 # これで仮実装では通らない 75 | 76 | def add(a, b): 77 | return a + b # 一般化 78 | 79 | # Step 3: エッジケースを追加 80 | def test_add_負の数(): 81 | assert add(-1, -2) == -3 82 | assert add(-5, 3) == -2 83 | ``` 84 | 85 | ## TDD実践時の注意点 86 | 87 | 1. **テストは1つずつ追加** - 一度に複数のテストを書かない 88 | 2. **小さく頻繁にコミット** - Red→Green、Refactor完了でコミット 89 | 3. **テストの粒度** - 1つのテストで1つの振る舞いをテスト 90 | 4. **リファクタリングの判断** - 重複コード、可読性、設計原則 91 | 5. **テストファーストの徹底** - 必ず失敗するテストから書く 92 | 93 | ## 実行コマンド 94 | 95 | ```bash 96 | # テストの実行 97 | make test # 全テスト実行 98 | make test-unit # 単体テストのみ 99 | make test-property # プロパティベーステストのみ 100 | make test-cov # カバレッジ付きテスト 101 | 102 | # 特定のテストを実行 103 | uv run pytest tests/unit/test_example.py::TestExampleClass::test_正常系_初期化時は空のリスト -v 104 | ``` 105 | 106 | このコマンドを使用することで、堅牢で保守性の高いテストスイートを構築できます。 107 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | name: 🐛 バグレポート 2 | description: バグを報告して改善に協力してください 3 | title: "[Bug]: " 4 | labels: ["bug", "triage"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | バグレポートを提出していただきありがとうございます! 11 | できるだけ詳細な情報を提供していただけると、問題の解決が早くなります。 12 | 13 | - type: textarea 14 | id: description 15 | attributes: 16 | label: バグの説明 17 | description: バグの内容を明確かつ簡潔に説明してください 18 | placeholder: | 19 | 何が起こったのか、何を期待していたのかを説明してください 20 | validations: 21 | required: true 22 | 23 | - type: textarea 24 | id: reproduction 25 | attributes: 26 | label: 再現手順 27 | description: バグを再現するための手順を記載してください 28 | placeholder: | 29 | 1. '...'を実行する 30 | 2. '...'をクリックする 31 | 3. '...'が表示される 32 | 4. エラーが発生する 33 | validations: 34 | required: true 35 | 36 | - type: textarea 37 | id: expected 38 | attributes: 39 | label: 期待される動作 40 | description: 本来どのような動作を期待していたか説明してください 41 | validations: 42 | required: true 43 | 44 | - type: textarea 45 | id: actual 46 | attributes: 47 | label: 実際の動作 48 | description: 実際にどのような動作が起こったか説明してください 49 | validations: 50 | required: true 51 | 52 | - type: textarea 53 | id: logs 54 | attributes: 55 | label: エラーログ 56 | description: 関連するエラーメッセージやスタックトレースがあれば貼り付けてください 57 | render: shell 58 | 59 | - type: dropdown 60 | id: python-version 61 | attributes: 62 | label: Python バージョン 63 | description: 使用している Python のバージョンを選択してください 64 | options: 65 | - Python 3.12 66 | - Python 3.13 67 | - その他 68 | validations: 69 | required: true 70 | 71 | - type: input 72 | id: os 73 | attributes: 74 | label: OS 75 | description: 使用している OS を記載してください 76 | placeholder: 例, Ubuntu 22.04, macOS 14.0, Windows 11 77 | validations: 78 | required: true 79 | 80 | - type: textarea 81 | id: additional 82 | attributes: 83 | label: 追加情報 84 | description: その他、問題の解決に役立つ情報があれば記載してください 85 | placeholder: | 86 | - 依存関係のバージョン 87 | - 環境変数 88 | - 設定ファイル 89 | など 90 | 91 | - type: checkboxes 92 | id: terms 93 | attributes: 94 | label: チェックリスト 95 | description: 以下の項目を確認してください 96 | options: 97 | - label: 同様の Issue が既に存在しないことを確認しました 98 | required: true 99 | - label: 最新バージョンで問題が発生することを確認しました 100 | required: true 101 | - label: 再現可能な最小限のコード例を提供できます 102 | required: false 103 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: ✨ 機能要望 2 | description: 新しい機能やアイデアを提案してください 3 | title: "[Feature]: " 4 | labels: ["enhancement", "triage"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: | 10 | 新しい機能の提案をありがとうございます! 11 | あなたのアイデアがプロジェクトをより良くする助けになります。 12 | 13 | - type: textarea 14 | id: problem 15 | attributes: 16 | label: 解決したい問題 17 | description: この機能要望に関連する問題や課題を説明してください 18 | placeholder: | 19 | 現在、〜という作業をする際に〜という問題があります。 20 | これは〜なので不便です。 21 | validations: 22 | required: true 23 | 24 | - type: textarea 25 | id: solution 26 | attributes: 27 | label: 提案する解決策 28 | description: どのような機能や改善を提案しますか? 29 | placeholder: | 30 | 〜という機能があれば、〜ができるようになります。 31 | 具体的には〜のような実装を想定しています。 32 | validations: 33 | required: true 34 | 35 | - type: textarea 36 | id: alternatives 37 | attributes: 38 | label: 検討した代替案 39 | description: 他に検討した解決方法があれば記載してください 40 | placeholder: | 41 | 他の方法として〜も考えましたが、〜という理由で提案する方法が良いと考えました。 42 | 43 | - type: textarea 44 | id: api-example 45 | attributes: 46 | label: API の使用例 47 | description: 提案する機能の使用例を示してください(該当する場合) 48 | render: python 49 | placeholder: | 50 | from project_name import NewFeature 51 | 52 | feature = NewFeature() 53 | result = feature.do_something() 54 | 55 | - type: dropdown 56 | id: priority 57 | attributes: 58 | label: 優先度 59 | description: この機能の重要度をどう考えますか? 60 | options: 61 | - 低(あれば便利) 62 | - 中(効率が大幅に向上する) 63 | - 高(これがないと困る) 64 | validations: 65 | required: true 66 | 67 | - type: textarea 68 | id: additional 69 | attributes: 70 | label: 追加のコンテキスト 71 | description: その他、この機能要望に関する情報があれば追加してください 72 | placeholder: | 73 | - 参考リンク 74 | - 類似機能を持つ他のプロジェクト 75 | - スクリーンショット 76 | など 77 | 78 | - type: checkboxes 79 | id: contribution 80 | attributes: 81 | label: 貢献について 82 | options: 83 | - label: この機能の実装に協力する意思があります 84 | required: false 85 | - label: この機能のテストに協力する意思があります 86 | required: false 87 | - label: この機能のドキュメント作成に協力する意思があります 88 | required: false 89 | 90 | - type: checkboxes 91 | id: terms 92 | attributes: 93 | label: チェックリスト 94 | description: 以下の項目を確認してください 95 | options: 96 | - label: 同様の機能要望が既に存在しないことを確認しました 97 | required: true 98 | - label: この機能がプロジェクトの目的に合致することを確認しました 99 | required: true 100 | -------------------------------------------------------------------------------- /.claude/commands/commit-and-pr.md: -------------------------------------------------------------------------------- 1 | # 変更のコミットとPR作成 2 | 3 | 現在の変更をコミットし、適切なブランチを作成してプルリクエストを作成します。CLAUDE.mdの「GitHub操作」セクションの規約に従います。 4 | 5 | ## 実行手順 6 | 7 | ### 1. 変更内容の確認 8 | ```bash 9 | git status # 変更ファイルの確認 10 | git diff # 変更内容の確認 11 | git log --oneline -10 # 最近のコミット履歴を確認 12 | ``` 13 | 14 | ### 2. コミットメッセージの作成 15 | CLAUDE.mdで定義されているフォーマットに従います: 16 | ``` 17 | <変更の種類>: <変更内容の要約> 18 | 19 | 詳細な説明(必要に応じて) 20 | 21 | 🤖 Generated with [Claude Code](https://claude.ai/code) 22 | 23 | Co-Authored-By: Claude 24 | ``` 25 | 26 | ### 3. ブランチ名の命名規則 27 | 変更の種類に応じて適切なプレフィックスを使用: 28 | - `feature/` - 機能追加 29 | - `fix/` - バグ修正 30 | - `refactor/` - リファクタリング 31 | - `docs/` - ドキュメント更新 32 | - `test/` - テスト追加・修正 33 | 34 | ### 4. ラベルの命名規則 35 | PRに付けるラベル: 36 | - `enhancement` - 機能追加 37 | - `bug` - バグ修正 38 | - `refactor` - リファクタリング 39 | - `documentation` - ドキュメント 40 | - `test` - テスト 41 | 42 | ### 5. 実行ステップ 43 | 44 | 1. **変更内容の分析** 45 | - git statusとgit diffで変更を確認 46 | - 変更の種類を判断(feature/fix/refactor/docs/test) 47 | 48 | 2. **ブランチの作成** 49 | ```bash 50 | git checkout -b / 51 | ``` 52 | 53 | 3. **ステージングとコミット** 54 | ```bash 55 | git add 56 | git commit -m "$(cat <<'EOF' 57 | : 58 | 59 | 60 | 61 | 🤖 Generated with [Claude Code](https://claude.ai/code) 62 | 63 | Co-Authored-By: Claude 64 | EOF 65 | )" 66 | ``` 67 | 68 | 4. **リモートへのプッシュ** 69 | ```bash 70 | git push -u origin 71 | ``` 72 | 73 | 5. **PRの作成** 74 | ```bash 75 | make pr TITLE="" BODY="" LABEL="