- name
- add-model
- description
- Use when adding a new module or component that follows an existing pattern in the codebase (e.g., a new API endpoint, model class, proposer, handler)
# Add Model
Step-by-step guide for adding a new module that follows an existing pattern.
## Step 0: Gather Required Information
Before implementation, collect all required information. If called from `issue-to-pr`,
the issue should provide these. If standalone, brainstorm with the user.
### Required Information Checklist
| # | Item | Description |
|---|------|-------------|
| 1 | **Name** | Module/component name and naming convention |
| 2 | **Definition** | What this module does, its responsibilities |
| 3 | **Type/Category** | Which directory/package it belongs to |
| 4 | **Interface** | What traits/interfaces/protocols it implements |
| 5 | **Fields/Parameters** | What data it holds or accepts |
| 6 | **Behavior** | Key methods and their semantics |
| 7 | **Reference implementation** | Existing module to use as template |
If any item is missing, ask the user. Do NOT proceed until complete.
## Step 1: Study Reference Implementation
Read the reference implementation identified in Step 0. Understand:
- File structure and organization pattern
- Required trait/interface implementations
- Registration/discovery mechanism (if any)
- Test patterns used
## Step 2: Implement
Create the new module following the reference pattern:
1. Create source file in the correct directory
2. Implement required interfaces/traits
3. Follow existing naming conventions
4. Register the module (mod.rs, __init__.py, index.ts, etc.)
## Step 3: Write Tests
Create tests alongside the implementation:
- Construction/initialization test
- Core behavior test (key methods work correctly)
- Edge cases and error handling
- Serialization round-trip (if applicable)
Link tests following project convention (inline, separate file, or test directory).
## Step 4: Register and Integrate
Update all registration points:
- Module registry (mod.rs, __init__.py, index.ts, etc.)
- CLI dispatch table (if applicable)
- Configuration files (if applicable)
- Documentation (if applicable)
## Step 5: Verify
Run project test and lint commands (from CLAUDE.md), then invoke
`workflow:review-implementation` to verify completeness.
## Common Mistakes
| Mistake | Fix |
|---------|-----|
| Skipping registration | Check all registration points from reference implementation |
| Inventing new patterns | Follow the reference — consistency over creativity |
| Missing test linkage | Follow project's test organization convention |
| Not reading CLAUDE.md | Project conventions are defined there, read first |
在 GitHub 查看