Skip to content

Commit 5a24ed6

Browse files
committed
feat: enforce creation of a spec file for every code change
1 parent d72c11f commit 5a24ed6

File tree

2 files changed

+65
-35
lines changed

2 files changed

+65
-35
lines changed

project-specs/index.spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
**ALL CODING AGENTS MUST:**
1010
1. **READ** this index file before making any technical recommendations
1111
2. **FOLLOW** all active specifications referenced here
12+
3. **EXECUTE SPECIFICATION SELECTION PROTOCOL** - Before creating new specs, scan existing spec names, select candidates, and determine reuse strategy (see [spec-management.rules.md](../rules/spec-management.rules.md))
1213
4. **UPDATE** this index when new spec files are created
1314

1415
---

rules/spec-management.rules.md

Lines changed: 64 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,44 @@ When coding agents need context for:
6464

6565
**WHEN ENCOUNTERING DECISION POINTS THAT REQUIRE SPECIFICATION:**
6666

67+
## SPECIFICATION SELECTION AND REUSE PROTOCOL
68+
69+
**MANDATORY: BEFORE CREATING NEW SPECIFICATIONS, AGENTS MUST:**
70+
71+
1. **SCAN EXISTING SPECIFICATION NAMES** - Review all spec filenames in `project-specs/` directory to identify potential matches
72+
2. **SELECT CANDIDATE SPECIFICATIONS** - Choose 2-3 specs whose names most closely match the current requirement
73+
3. **READ CANDIDATE SPECIFICATIONS** - Examine selected specs for relevant content and applicability
74+
4. **DETERMINE SPECIFICATION STRATEGY:**
75+
- **REUSE EXISTING:** If a spec fully covers the requirement, use it and update if needed
76+
- **EXTEND EXISTING:** If a spec partially covers the requirement, update it with additional sections
77+
- **CREATE SUPPORTING SPEC:** If existing spec is too specific, create a complementary spec with clear separation of concerns
78+
- **CREATE NEW SPEC:** Only if no existing spec is relevant or applicable
79+
80+
**SPECIFICATION NAMING REQUIREMENTS:**
81+
- **DETAILED AND SPECIFIC:** Spec names MUST be descriptive enough to identify content from filename alone
82+
- **SCOPE INDICATION:** Include scope indicators (e.g., `user-authentication.spec.md`, `api-error-handling.spec.md`)
83+
- **AVOID GENERIC NAMES:** Never use vague names like `general.spec.md` or `misc.spec.md`
84+
85+
**CONFLICT RESOLUTION PROTOCOL:**
86+
When uncertain between 2+ existing specifications:
87+
- **ASK USER FOR GUIDANCE** - **USE `run_command` TOOL** - Present options and ask user to select preferred spec or approve new spec creation
88+
- **PROVIDE CONTEXT** - Explain why each candidate spec might be relevant
89+
- **WAIT FOR APPROVAL** - Do not proceed until user provides clear direction
90+
91+
**STANDARD WORKFLOW:**
92+
6793
1. **READ EXISTING SPECIFICATIONS** - Check `project-specs/index.spec.md` first
6894
2. **FOLLOW EXISTING PATTERNS** - Use established patterns if applicable (see `project-specs/index.spec.md` for documented patterns)
69-
3. **PAUSE IMPLEMENTATION** - Stop coding when new decisions are needed
70-
4. **ASK CLARIFYING QUESTIONS** - **USE `run_command` TOOL** for all questions - **MUST FOLLOW** [rules/interactive-input.rules.md](./interactive-input.rules.md) for context on using run_command tool
71-
5. **RESEARCH OPTIONS** - Present alternatives with trade-offs
72-
6. **PROPOSE SPECIFICATION** - Create spec file with decision rationale
73-
7. **WAIT FOR APPROVAL** - **USE `run_command` TOOL** for approval questions - **MUST FOLLOW** [rules/interactive-input.rules.md](./interactive-input.rules.md) for context on using run_command tool
74-
8. **DOCUMENT USER DECISIONS** - **MANDATORY:** After ANY user decision or choice, ask: "Should this decision be documented in the relevant spec file for future reference?" - **USE `run_command` TOOL** - **MUST FOLLOW** [rules/interactive-input.rules.md](./interactive-input.rules.md) for context on using run_command tool
75-
9. **ADD SPEC REFERENCES TO CODE** - **MANDATORY:** When implementing features based on specifications, ALL generated code files MUST include spec reference comments - **FOLLOW:** [rules/spec-reference.rules.md](./spec-reference.rules.md) for complete requirements and formats
76-
10. **RE-READ SPECIFICATIONS** - **MANDATORY:** Read all relevant specs immediately before implementation to ensure most current information
77-
11. **IMPLEMENT ACCORDING TO SPEC** - Follow approved specification exactly
95+
3. **EXECUTE SPECIFICATION SELECTION PROTOCOL** - Follow the mandatory selection and reuse process above
96+
4. **PAUSE IMPLEMENTATION** - Stop coding when new decisions are needed
97+
5. **ASK CLARIFYING QUESTIONS** - **USE `run_command` TOOL** for all questions - **MUST FOLLOW** [rules/interactive-input.rules.md](./interactive-input.rules.md) for context on using run_command tool
98+
6. **RESEARCH OPTIONS** - Present alternatives with trade-offs
99+
7. **PROPOSE SPECIFICATION** - Create spec file with decision rationale
100+
8. **WAIT FOR APPROVAL** - **USE `run_command` TOOL** for approval questions - **MUST FOLLOW** [rules/interactive-input.rules.md](./interactive-input.rules.md) for context on using run_command tool
101+
9. **DOCUMENT USER DECISIONS** - **MANDATORY:** After ANY user decision or choice, ask: "Should this decision be documented in the relevant spec file for future reference?" - **USE `run_command` TOOL** - **MUST FOLLOW** [rules/interactive-input.rules.md](./interactive-input.rules.md) for context on using run_command tool
102+
10. **ADD SPEC REFERENCES TO CODE** - **MANDATORY:** When implementing features based on specifications, ALL generated code files MUST include spec reference comments - **FOLLOW:** [rules/spec-reference.rules.md](./spec-reference.rules.md) for complete requirements and formats
103+
11. **RE-READ SPECIFICATIONS** - **MANDATORY:** Read all relevant specs immediately before implementation to ensure most current information
104+
12. **IMPLEMENT ACCORDING TO SPEC** - Follow approved specification exactly
78105

79106
**AGENT QUESTIONING PROTOCOL FOR SPECIFICATION DOCUMENTATION:**
80107
Before creating any specification file, agents MUST ask these questions to ensure optimal documentation:
@@ -113,32 +140,34 @@ Before creating any specification file, agents MUST ask these questions to ensur
113140
## MANDATORY SPEC-FIRST ENFORCEMENT RULE
114141

115142
**CRITICAL VIOLATIONS:**
116-
- Implementing code without checking existing specifications = CRITICAL VIOLATION
117-
- Making architectural decisions without creating specification = CRITICAL VIOLATION
118-
- Proceeding with implementation before user approval = CRITICAL VIOLATION
119-
120-
**DECISION IMPACT CATEGORIES:**
121-
122-
**HIGH IMPACT DECISIONS** (ALWAYS require specification):
123-
- Core architecture changes
124-
- New external dependencies
125-
- Database schema changes
126-
- Authentication/authorization systems
127-
- State management patterns
128-
- API design patterns
129-
130-
**MEDIUM IMPACT DECISIONS** (Usually require specification):
131-
- Component structure patterns
132-
- Styling approaches
133-
- Testing strategies
134-
- Build/deployment configurations
135-
- Error handling patterns
136-
137-
**LOW IMPACT DECISIONS** (May require specification if establishing patterns):
138-
- Individual component implementations
139-
- Utility function designs
140-
- Minor styling choices
141-
- Variable naming conventions
143+
- Implementing ANY code change without checking existing specifications = CRITICAL VIOLATION
144+
- Making ANY code modification without creating specification = CRITICAL VIOLATION
145+
- Proceeding with ANY implementation before user approval = CRITICAL VIOLATION
146+
- Modifying, adding, or deleting ANY code without specification documentation = CRITICAL VIOLATION
147+
148+
**MANDATORY SPECIFICATION REQUIREMENT:**
149+
150+
**ALL CODE CHANGES** (ALWAYS require specification - NO EXCEPTIONS):
151+
- **New Features:** Any new functionality, components, functions, endpoints, or capabilities
152+
- **Bug Fixes:** Any correction of existing code behavior or functionality
153+
- **Refactoring:** Any restructuring, optimization, or code improvement without changing external behavior
154+
- **Configuration Changes:** Any modification to build tools, environment settings, or project configuration
155+
- **Dependency Changes:** Adding, removing, or updating any external libraries or packages
156+
- **Documentation Updates:** Changes to code comments, README files, or technical documentation
157+
- **Testing Changes:** Adding, modifying, or removing tests at any level
158+
- **Performance Optimizations:** Any changes aimed at improving system performance
159+
- **Security Updates:** Any changes related to security, authentication, or authorization
160+
- **Maintenance Tasks:** Code cleanup, formatting changes, or routine maintenance
161+
- **Architecture Changes:** Any modification to system structure, patterns, or design
162+
- **Database Changes:** Schema modifications, query updates, or data migration scripts
163+
- **API Changes:** Endpoint modifications, request/response format changes, or protocol updates
164+
- **UI/UX Changes:** Any modification to user interface or user experience elements
165+
- **Infrastructure Changes:** Deployment, CI/CD, or environment configuration modifications
166+
167+
**CRITICAL ENFORCEMENT:**
168+
- **NO EXCEPTIONS:** Every single code modification requires a specification document
169+
- **BEFORE IMPLEMENTATION:** Specifications must be created and approved before any coding begins
170+
- **COMPLETE COVERAGE:** No code change is too small to require specification documentation
142171

143172
**ARCHITECTURAL PATTERNS:**
144173
- Component architecture (atomic design, feature-based, etc.)

0 commit comments

Comments
 (0)