nanolang / code-quality
Cursor rule628 starsChanged 4 months agoApache-2.0View on GitHub
Code quality standards, parser architecture patterns, and development conventions
We split this RULE.md into the rules it gives an agent
20 rules. About 0 are common, 10 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
If you add a new language feature to nanolang:
- Very specific: line 13
Add feature to src/parser.c first
- Distinctive: line 14
Ensure C compiler handles it (100% support required)
- Very specific: line 17
Add corresponding AST struct in parser_mvp.nano
- Distinctive: line 20
Add token helpers if needed
- Very specific: line 23
Run ./bin/nanoc src_nano/parser_mvp.nano - must pass ✅
- Very specific: line 25
Run make examples - must build ✅
- Distinctive: line 28
Update feature lists in markdown docs
- Very specific: line 43
Add to ParseNodeType enum
- Distinctive: line 44
Create AST struct definition
- Distinctive: line 45
Add list field to Parser struct
- Distinctive: line 46
Add count field to Parser struct
- Very specific: line 49
Create parser_store_* function (copy pattern from existing)
- Very specific: line 50
Add parsing logic to appropriate parse_* function
- Distinctive: line 56
Use functional style (return new Parser)
- Very specific: line 57
No mutations except with mut keyword
- Very specific: line 72
Use parser_with_error for syntax errors
- Distinctive: line 81
Must compile itself in < 10 seconds
- Distinctive: line 90
Document WHY, not WHAT
- Distinctive: line 147
NO commits that break tests, ever
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Quality Standards
When Adding Language Features
If you add a new language feature to nanolang:
- Stage 0 (C Compiler):
- Add feature to
src/parser.cfirst - Ensure C compiler handles it (100% support required)
- Add feature to
- Stage 2 (Self-Hosted Parser):
- Add corresponding AST struct in
parser_mvp.nano - Add
parser_store_*function - Integrate into parsing logic (critical!)
- Add token helpers if needed
- Add corresponding AST struct in
- Testing:
- Run
./bin/nanoc src_nano/parser_mvp.nano- must pass ✅ - Run
./tests/run_all_tests.sh- must pass ✅ - Run
make examples- must build ✅
- Run
- Documentation:
- Update feature lists in markdown docs
- Update completion percentages
Parser Architecture
Current Status
The self-hosted parser has:
- 31 node types (complete)
- 29 AST structs (complete)
- 67 Parser fields (complete)
- 22+ parsing functions (production-ready)
Adding New Node Types
- Add to
ParseNodeTypeenum - Create AST struct definition
- Add list field to Parser struct
- Add count field to Parser struct
- Initialize in
parser_init_ast_lists - Initialize in
parser_new - Create
parser_store_*function (copy pattern from existing) - Add parsing logic to appropriate
parse_*function - Test immediately
Code Patterns
Follow existing patterns:
- Use functional style (return new Parser)
- No mutations except with
mutkeyword - Consistent error handling
- Shadow tests for validation
Parser Changes
- Never break existing functionality
- Always add shadow tests for new functions
- Keep architecture consistent
- Document complex logic
Error Handling
Parser Errors
- Use
parser_with_errorfor syntax errors - Include line/column information
- Provide clear error messages
- Never silently fail
Performance Standards
Parser Performance
- Must compile itself in < 10 seconds
- No memory leaks
- Reasonable file size (< 5000 lines preferred)
- Clean compilation (no warnings)
Documentation Standards
Code Comments
- Document WHY, not WHAT
- Complex algorithms need explanation
- Edge cases should be noted
- TODOs must have tracking
Git Workflow
Branch Names
feat/*- New featuresfix/*- Bug fixesdocs/*- Documentation onlytest/*- Test additions
Commit Messages
Format:
type: Brief description
Detailed explanation if needed
- Changes made
- Tests: status
- Self-hosting: statusTypes: feat, fix, docs, test, refactor, perf
Pre-Commit Checklist
# 1. Compile check
./bin/nanoc src_nano/parser_mvp.nano || exit 1
# 2. Test check
./tests/run_all_tests.sh || exit 1
# 3. Self-hosting check
./bin/nanoc src_nano/lexer_complete.nano || exit 1Future-Proofing
When at 100% Completion
Once parser reaches 100% feature coverage:
- Lock Feature Parity:
Any C parser feature MUST have self-hosted equivalent - Test Coverage:
New features MUST include tests - Documentation:
Feature docs MUST be complete before merge - Green Status:
NO commits that break tests, ever
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/file-organization/RULE.mdCursor rule
- .cursor/rules/testing-standards/RULE.mdCursor rule
- github-issue-trackingSkill
- nanovm-opcode-debuggingSkill
- reading-nanolangSkill
- release-readinessSkill
- releasing-documentationSkill
- releasing-presentationSkill
- releasingSkill
- roadmap-executionSkill
- session-completionSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

