This document describes how to implement planned features. The /implement command automates this workflow.
Before implementing:
- A plan exists (Linear issue, and ADR for large features)
- You understand what needs to be done
- The work fits in a single session (split if not)
-
Get the issue details: use the Linear MCP
get_issuetool with the issue ID (e.g.,RUE-42) -
For large features, read the ADR:
- Find it in
docs/designs/ - Identify which phase you're implementing
- Understand how this phase fits into the whole
- Find it in
-
Mark work in progress: use
save_issuewith state "In Progress" and assignee "me"
Verify the work fits in the current session:
Good scope (proceed):
- Clear, bounded changes
- 1-5 files to modify
- Single logical unit of work
Too large (split it):
- More than 5-7 files
- Multiple unrelated changes
- Would require extensive exploration
If too large, create sub-issues: use save_issue ("Subtask: ", task label) with parentId set to the current issue.
Then implement sub-issues one at a time.
Follow this order for consistent, reviewable changes:
Edit files in docs/spec/src/:
- Add or modify paragraphs with proper ID markers:
{{ rule(id="X.Y:Z", cat="category") }} - Categories:
normative,legality-rule,dynamic-semantics,syntax,undefined-behavior(gated — require test coverage);example,informative(not gated) - Prose register, ID discipline, and the folk-term ban: see the spec prose rubric
Spec tests (crates/rue-spec/cases/):
- For language semantics
- Must include
spec = ["X.Y:Z"]references to spec paragraphs - Traceability check enforces 100% coverage
UI tests (crates/rue-ui-tests/cases/):
- For warnings, diagnostics, compiler flags
- Not tied to spec paragraphs
Unit tests (in crate source with #[cfg(test)]):
- For internal implementation details
- Data structure methods, algorithms, edge cases
Follow existing patterns. Key considerations:
Multi-backend consistency: If touching rue-codegen, implement in ALL backends:
x86_64/- Linux x86-64aarch64/- macOS ARM64
Check: mir.rs, emit.rs, regalloc.rs, liveness.rs, cfg_lower.rs
Index-based references: Use u32 indices, not pointers. Check for dangling indices.
Span tracking: Maintain source locations for error reporting.
If this is a large feature behind a preview gate:
Add tests with preview flag:
[[case]]
name = "my_feature_test"
preview = "my_feature"
source = """..."""
exit_code = 42Add semantic gates:
if using_preview_syntax {
self.require_preview(PreviewFeature::MyFeature, "feature description", span)?;
}Preview tests use xfail semantics until the feature is complete: ordinary
assertion failures are ignored, while fatal subprocess failures and unexpected
passes fail the suite. Add preview_should_pass = true as each assertion works.
Run the full test suite:
./test.shThis runs (via buck2 test //... plus the repository quality gates):
- Unit tests for all crates
- Spec tests and the spec-traceability gate
- UI tests (diagnostics) and CLI integration tests
- Tutorial snippet checks and ADR registry validation
For stable work: All tests must pass.
For preview features: Stable tests must pass. Preview tests for your feature should pass when your phase is complete.
For large features, update the ADR checkbox:
## Implementation Phases
- [x] **Phase 1: Core parsing** - RUE-42
- [ ] **Phase 2: Type checking** - RUE-43- Run code review:
/code-review(see code-review.md) - Fix any blocking issues
- Commit:
/commit(see committing.md)
When all phases are complete:
- Remove preview gates from spec tests (delete
preview = "...") - Remove
require_preview()calls from semantic analysis - Remove the feature from
PreviewFeatureenum - Update ADR status to "Implemented"
- Fill in frontmatter dates (
implemented:) - Create stabilization commit
- Lexer: Add token in
rue-lexer - Parser: Add parsing in
rue-parser - RIR: Add IR node in
rue-rir - AIR: Add typed node in
rue-air - Sema: Add type checking in the
rue-air/src/sema/module - Codegen: Add code generation in both backends
- Add its representation in
rue-air/src/types.rs(Typeis au32interned intoTypeInternPool, not an enum); built-in types are synthetic structs defined inrue-builtins(ADR-0020), not hardcoded variants - Update type checking in sema
- Update code generation for the type's operations
- Add spec chapter and tests
- Parser: Add syntax handling
- RIR/AIR: Add IR representation
- Sema: Add semantic analysis
- Codegen: Add code generation
- Spec: Document the syntax and semantics