python-standards
Skill12 starsChanged 7 months agoMITView on GitHub
Python coding standards for Amplifier including type hints, async patterns, error handling, and formatting. Use when writing Python code for Amplifier modules.
We split this skill into the rules it gives an agent
5 rules. 0 are common, 3 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 117
Files must end with newline: - Add blank line at EOF
- Very specific: line 139
Never manually edit pyproject.toml dependencies: - Use uv add
- Very specific: line 209
Run make check before committing
- Distinctive: line 210
Keep modules focused and simple
- Distinctive: line 212
Test at the protocol level
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Coding Standards
Type Hints
ALL functions must have complete type hints:
from typing import Any
async def process_data(items: list[str], config: dict[str, Any]) -> dict[str, Any]:
"""Process data items with configuration."""
results = {}
for item in items:
results[item] = await transform(item, config)
return resultsInclude type hints for self:
class MyClass:
def __init__(self: "MyClass", name: str) -> None:
self.name = name
async def process(self: "MyClass") -> str:
return f"Processing {self.name}"Async Patterns
All I/O operations must be async:
# Good
async def read_file(path: Path) -> str:
content = path.read_text() # For now, sync is OK
return content
# Better (when using async libraries)
async def read_file(path: Path) -> str:
async with aiofiles.open(path) as f:
return await f.read()Use asyncio.gather for parallel operations:
async def process_files(files: list[Path]) -> list[dict]:
tasks = [process_file(f) for f in files]
return await asyncio.gather(*tasks)Error Handling
Return errors, don't raise:
from amplifier_core import ToolResult
async def execute(self: "MyTool", input: dict[str, Any]) -> ToolResult:
"""Execute tool operation."""
try:
result = await self._process(input)
return ToolResult(success=True, output=result)
except ValueError as e:
logger.error(f"Validation error: {e}")
return ToolResult(success=False, error={"message": str(e)})Provide clear error messages:
# Good
return ToolResult(
success=False,
error={"message": f"File not found: {path}"}
)
# Bad
return ToolResult(
success=False,
error={"message": "Error"}
)Formatting
Line length: 120 characters
Import organization:
# Standard library
import asyncio
import logging
from pathlib import Path
from typing import Any
# Third-party
import yaml
from pydantic import BaseModel
# Local/Amplifier
from amplifier_core import ModuleCoordinator, ToolResultFiles must end with newline - Add blank line at EOF
Use ruff for formatting:
uv run ruff format .
uv run ruff check . --fixDependencies
Use uv for dependency management:
# Add dependency
cd amplifier-module-tool-mytool
uv add package-name
# Add dev dependency
uv add --dev pytest ruff pyrightNever manually edit pyproject.toml dependencies - Use uv add
Testing
Test behavior at protocol level:
import pytest
from amplifier_core.testing import TestCoordinator
@pytest.mark.asyncio
async def test_tool_basic():
"""Test basic tool functionality."""
coordinator = TestCoordinator()
# Mount module
await mount(coordinator, {"timeout": 10})
# Get and test
tool = coordinator.get("tools", "my-tool")
result = await tool.execute({"param": "value"})
assert result.success
assert "expected" in result.outputTest pyramid: 60% unit, 30% integration, 10% end-to-end
Common Pitfalls
Don't use blocking I/O
# Bad
content = requests.get(url).text
# Good
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
content = await response.text()Don't modify module internals from outside
# Bad
tool._internal_state = new_value
# Good
await tool.execute({"operation": "update", "value": new_value})Don't put logic in mount()
# Bad
async def mount(coordinator, config):
tool = MyTool()
await tool.initialize_database() # Heavy logic
await coordinator.mount("tools", tool)
# Good
async def mount(coordinator, config):
tool = MyTool(config) # Light initialization only
await coordinator.mount("tools", tool)
# Heavy logic happens in execute(), not mount()Remember
- Run
make checkbefore committing - Keep modules focused and simple
- Document public interfaces
- Test at the protocol level
Other versions7 projects use a version of this.
Word for word · 1
- microsoft/amplifier-module-tool-skills★ 8100% same
Edited · 0
None found.
Wrote their own version · 6
- L-1124/QQMusicApi★ 502same name
- alphacrack/readme2demo★ 9same name
- rishapgandhi/python-skills★ 4same name
- motola10/claude-code-base★ 1same name
- pablolok/claude-skills★ 1same name
- takayoshitoyoda05/claude-ml-template★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository32 other files it gives its agents.
- amplifier-philosophySkill
- module-developmentSkill
- adapt-skillSkill
- bet-sizerSkill
- bug-reportSkill
- code-reviewSkill
- council-hereSkill
- councilifySkill
- councilSkill
- cranky-old-samSkill
- create-demo-videoSkill
- crusty-old-engineerSkill
- engineering-patternsSkill
- image-visionSkill
- intent-keeperSkill
- mass-changeSkill
- monitorSkill
- outcome-cartographerSkill
- outcomistSkill
- personafySkill
- positioning-criticSkill
- product-council-hereSkill
- product-councilSkill
- restless-old-brianSkill
- retrospectiveSkill
- second-opinionSkill
- session-debugSkill
- skillifySkill
- skills-assistSkill
- tester-breakerSkill
- user-advocateSkill
- verification-disciplineSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

