code-rules
Code Rules
Universal rules for all languages + index to language-specific guides.
Language Rules
Should USE ‘English’ for all code comments, docstrings, and commit messages. This ensures clarity and consistency across projects and collaborators.
Tier 1: Essential (Universal)
ALWAYS follow these. No exceptions.
- Format before commit: Run the language-specific formatter
- Type hints / annotations: Required on all public functions
- No magic: No hidden side effects, no implicit behavior
- Tests: Write tests for new functionality
- Docstrings: On modules, classes, and public functions
Pre-Commit Documentation Check
Before committing, ask yourself:
- Did I add something new? (feature, file, module, command) → Is it documented?
- Did I remove or rename something? → Are old references cleaned up?
- Did I change behavior? (API, output, flags) → Are docs updated?
- Did I add dependencies? → Are they recorded? (requirements, package.json, etc.)
- Did I add code that needs a docstring? → Did I write it?
If any answer is "needs update" → update docs first, then commit everything together.
Commit Messages
-
- Each commit should focus on one thing. If the workspace has 3 changes, make 3 separate commits
-
- Documentation updates should be a separate commit. Reference the triggering commit in the message, e.g., "Update docs for X after Y commit" or standalone docs updates
-
- Format:
<type>(<scope>): <subject>where:
<type>: feat, fix, docs, style, refactor, test, chore<scope>: optional area of code affected (e.g. module name)<subject>: brief description of change (max 50 chars), English
- Format:
Language Index
PLEASE FOLLOW THE LANGUAGE-SPECIFIC GUIDES FOR EACH LANGUAGE YOU USE. They contain important style rules and tool recommendations.
| Language | Guide File | Key Tools |
|---|---|---|
| Python | languages/python.md |
uv, ruff, pytest |
| Lean | languages/lean.md |
lake, mathlib style |
Common Mistakes (All Languages)
- ❌ Skipping format/lint before commit
- ❌ Missing type annotations on public APIs
- ❌ No docstrings on modules and classes
- ❌ Writing code before writing tests
- ❌ Committing without checking if docs need updating
More from frankieew/agent-skills
pr-worktree-workflow
Complete workflow for creating git worktrees and Pull Requests, including worktree setup, branch management, and PR creation.
11mathlib-workflow
Complete workflow for contributing to mathlib (Lean 4), including repo setup, git workflow, PR creation, and review process.
6tmux
>
4mathlib-style
Code style guide for mathlib (Lean 4), including naming conventions, formatting rules, and documentation requirements.
4lmfdb-cli
>
2ssh
>
1