From 76e0d093c955b7a96ef74330cb67076e14f76412 Mon Sep 17 00:00:00 2001 From: "Michael J. Jabbour" Date: Mon, 30 Mar 2026 17:22:48 -0400 Subject: [PATCH] compress: convert python-dev-instructions to on-demand skill - Created skills/python-dev-reference/SKILL.md with full python_check tool reference (7 mentions), pyproject.toml configuration details (3 mentions), and CLI Usage section documenting all invocation patterns. - Registered skill via Option B (tool-skills module) in behaviors/python-dev.yaml, adding the tool-skills module with source pointing to amplifier-module-tool-skills and config referencing '@python-dev:skills' directory. - Trimmed context/python-dev-instructions.md to ~185 tokens (from ~1035 tokens), retaining python_check tool awareness, Auto-checking Hook section explaining post-edit auto-run behaviour, and a load_skill() pointer to the full reference. - Net savings: ~850 tokens per session that do not need the full reference, with full detail available on demand via load_skill('python-dev-reference'). --- behaviors/python-dev.yaml | 6 ++ context/python-dev-instructions.md | 107 +------------------------ skills/python-dev-reference/SKILL.md | 114 +++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 104 deletions(-) create mode 100644 skills/python-dev-reference/SKILL.md diff --git a/behaviors/python-dev.yaml b/behaviors/python-dev.yaml index 75f3529..b561d0f 100644 --- a/behaviors/python-dev.yaml +++ b/behaviors/python-dev.yaml @@ -24,6 +24,12 @@ tools: - types - stubs + - module: tool-skills + source: git+https://github.com/microsoft/amplifier-module-tool-skills@main + config: + skills: + - "@python-dev:skills" + # Hooks provided by this behavior hooks: - module: hooks-python-check diff --git a/context/python-dev-instructions.md b/context/python-dev-instructions.md index ae3c2f6..8fcdcd4 100644 --- a/context/python-dev-instructions.md +++ b/context/python-dev-instructions.md @@ -1,108 +1,7 @@ # Python Development Tools -This bundle provides comprehensive Python development capabilities for Amplifier. +Python code quality via `python_check` (ruff + pyright). Code intelligence via `python-dev:code-intel` agent. -## Available Tools +## Auto-checking Hook -### python_check - -Run code quality checks on Python files or code content. - -``` -python_check(paths=["src/"]) # Check a directory -python_check(paths=["src/main.py"]) # Check a specific file -python_check(content="def foo(): ...") # Check code string -python_check(paths=["src/"], fix=True) # Auto-fix issues -``` - -**Checks performed:** -- **ruff format**: Code formatting (PEP 8 style) -- **ruff lint**: Linting rules (pycodestyle, pyflakes, isort, bugbear, comprehensions, etc.) -- **pyright**: Static type checking -- **stub detection**: TODOs, placeholders, incomplete code - -### LSP Tools (via lsp-python) - -Semantic code intelligence for Python: - -| Tool | Use For | -|------|---------| -| `hover` | Get type info and docstrings | -| `goToDefinition` | Find where a symbol is defined | -| `findReferences` | Find all usages of a symbol | -| `incomingCalls` | What calls this function? | -| `outgoingCalls` | What does this function call? | - -## Automatic Checking Hook - -When enabled, Python files are automatically checked after write/edit operations. - -**Behavior:** -- Triggers on `write_file`, `edit_file`, and similar tools -- Checks `*.py` files only -- Runs lint and type checks (fast subset) -- Injects issues into agent context for awareness - -**Configuration** (in `pyproject.toml`): -```toml -[tool.amplifier-python-dev.hook] -enabled = true -file_patterns = ["*.py"] -report_level = "warning" # error | warning | info -auto_inject = true -``` - -## CLI Usage - -For standalone use outside Amplifier: - -```bash -# Install and run -uvx --from git+https://github.com/microsoft/amplifier-bundle-python-dev amplifier-python-check src/ - -# With options -amplifier-python-check src/ --fix # Auto-fix issues -amplifier-python-check src/ --format=json # JSON output for CI -amplifier-python-check src/ --no-types # Skip type checking -``` - -## Configuration - -Configure via `pyproject.toml`: - -```toml -[tool.amplifier-python-dev] -# Enable/disable specific checks -enable_ruff_format = true -enable_ruff_lint = true -enable_pyright = true -enable_stub_check = true - -# Paths to exclude -exclude_patterns = [ - ".venv/**", - "__pycache__/**", - "build/**", -] - -# Behavior -fail_on_warning = false # Exit code 1 on warnings -auto_fix = false # Auto-fix by default - -[tool.amplifier-python-dev.hook] -enabled = true -file_patterns = ["*.py"] -report_level = "warning" -auto_inject = true -``` - -## Best Practices - -See @python-dev:context/PYTHON_BEST_PRACTICES.md for the full development philosophy. - -**Key points:** -1. Run `python_check` after writing Python code -2. Fix issues immediately - don't accumulate debt -3. Use LSP tools to understand code before modifying -4. Type hints at boundaries, not everywhere -5. Readability over cleverness +After write/edit operations on `*.py` files, checks run automatically and inject issues into agent context. Configure via `pyproject.toml` under `[tool.amplifier-python-dev.hook]` (e.g., `enabled`, `report_level`, `file_patterns`). For full tool reference, configuration options, and CLI usage, use `load_skill(skill_name='python-dev-reference')`. diff --git a/skills/python-dev-reference/SKILL.md b/skills/python-dev-reference/SKILL.md new file mode 100644 index 0000000..4ecb3af --- /dev/null +++ b/skills/python-dev-reference/SKILL.md @@ -0,0 +1,114 @@ +--- +name: python-dev-reference +description: 'Full Python development tool reference — python_check usage, auto-checking hook configuration, CLI commands, pyproject.toml options, and best practices' +version: 1.0.0 +--- + +# Python Development Tools + +This bundle provides comprehensive Python development capabilities for Amplifier. + +## Available Tools + +### python_check + +Run code quality checks on Python files or code content. + +```python +python_check(paths=["src/"]) # Check a directory +python_check(paths=["src/main.py"]) # Check a specific file +python_check(content="def foo(): ...") # Check code string +python_check(paths=["src/"], fix=True) # Auto-fix issues +``` + +**Checks performed:** +- **ruff format**: Code formatting (PEP 8 style) +- **ruff lint**: Linting rules (pycodestyle, pyflakes, isort, bugbear, comprehensions, etc.) +- **pyright**: Static type checking +- **stub detection**: TODOs, placeholders, incomplete code + +### LSP Tools (via lsp-python) + +Semantic code intelligence for Python: + +| Tool | Use For | +|------|---------| +| `hover` | Get type info and docstrings | +| `goToDefinition` | Find where a symbol is defined | +| `findReferences` | Find all usages of a symbol | +| `incomingCalls` | What calls this function? | +| `outgoingCalls` | What does this function call? | + +## Automatic Checking Hook + +When enabled, Python files are automatically checked after write/edit operations. + +**Behavior:** +- Triggers on `write_file`, `edit_file`, and similar tools +- Checks `*.py` files only +- Runs lint and type checks (fast subset) +- Injects issues into agent context for awareness + +**Configuration** (in `pyproject.toml`): +```toml +[tool.amplifier-python-dev.hook] +enabled = true +file_patterns = ["*.py"] +report_level = "warning" # error | warning | info +auto_inject = true +``` + +## CLI Usage + +For standalone use outside Amplifier: + +```bash +# Install and run +uvx --from git+https://github.com/microsoft/amplifier-bundle-python-dev amplifier-python-check src/ + +# With options +amplifier-python-check src/ --fix # Auto-fix issues +amplifier-python-check src/ --format=json # JSON output for CI +amplifier-python-check src/ --no-types # Skip type checking +``` + +## Configuration + +Configure via `pyproject.toml`: + +```toml +[tool.amplifier-python-dev] +# Enable/disable specific checks +enable_ruff_format = true +enable_ruff_lint = true +enable_pyright = true +enable_stub_check = true + +# Paths to exclude +exclude_patterns = [ + ".venv/**", + "__pycache__/**", + "build/**", +] + +# Behavior +fail_on_warning = false # Exit code 1 on warnings +auto_fix = false # Auto-fix by default + +[tool.amplifier-python-dev.hook] +enabled = true +file_patterns = ["*.py"] +report_level = "warning" +auto_inject = true +``` + +## Best Practices + +See @python-dev:context/PYTHON_BEST_PRACTICES.md for the full development philosophy. + +**Key points:** +1. Run `python_check` after writing Python code +2. Fix issues immediately - don't accumulate debt +3. Use LSP tools to understand code before modifying +4. Type hints at boundaries, not everywhere +5. Readability over cleverness