asarchami/dotfiles/python-contract-docstrings
- community
Checking that the SKILL.md file is still in the repository.
Write docstrings that document each function's contract — what it requires of callers, what it guarantees, and how it fails. Analyses input invariants, errors raised on violation, errors from external state, and silenced errors.
Install
npx vskill@latest install asarchami/dotfiles/python-contract-docstringsSKILL.md
Contract Docstrings
Read Python source files, analyse each function's actual behaviour, and write docstrings that document the function's contract — what it demands and guarantees.
Most docstrings describe what a function does. These docstrings describe what a function demands and guarantees.
Scope
- If the user names specific files or directories, scope work to those.
- Skip trivial functions (one-liners, simple property accessors,
__repr__).
Workflow
- Read deeply. Trace every code path. Read callees. Read callers. Build a picture of real constraints.
- Analyse the contract. For each function, answer the four questions in the analysis checklist.
- Write docstrings. Add or replace docstrings using the format below.
- Verify. Run the test suite and type checker after editing.
Analysis Checklist
1. Input invariants (preconditions)
What must be true about the arguments for the function to behave correctly? Look beyond the type signature.
Look at: guard clauses, assertions, unhandled exception paths, implicit assumptions (iterating twice means it can't be a single-use iterator), relationships between arguments.
2. Errors raised on invariant violation
What happens when preconditions are violated?
- Explicit check — document the exception type.
- Implicit fail —
TypeError,KeyError,IndexErrorfrom side effects. - Silently wrong — most dangerous. Document if wrong input silently produces garbage.
3. Errors from external state
Filesystem, network, database, environment variables, global mutable state. For each, document what errors can result and whether they're handled.
4. Silenced errors
Exceptions caught and hidden: bare except:, contextlib.suppress(), .get() defaults masking missing keys, broad handlers that return defaults.
Docstring Format
Use Google style. Contract sections go after any existing summary:
Critical Rules
- Read before writing. Never write contract docstrings for code you haven't read thoroughly.
- Accuracy over completeness. If unsure, leave it out.
- Don't change behaviour. You are writing docstrings, not refactoring code.
- Trace callees. Don't assume what a function raises — read it.
Cross-References
python-documentation— Google-style docstring format, Sphinxpython-try-except— auditing error handling
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdot_claude/skills/python-contract-docstrings/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/asarchami/dotfiles/python-contract-docstrings)