This file provides instructions for AI agents working on this codebase. It encodes the SpecOps methodology—a specification-driven approach to software development and legacy system modernization.
The specification is the source of truth. All code implements behavior defined in specifications. When in doubt, defer to the spec. If the spec is unclear or incomplete, flag it for human review rather than making assumptions.
- Read specifications before code. Before implementing, modifying, or analyzing any feature, locate and read the relevant specification in the
specifications/directory. - Propose spec changes before code changes. If implementation requires behavior not covered by a specification, draft a specification update for human review before writing code.
- Never implement undocumented behavior. All system behavior must trace back to a verified specification.
- Domain experts verify specifications, not code. Specifications are written in plain language so non-technical stakeholders can review them. Code is an implementation detail.
- Flag ambiguity for human review. When specifications contain ambiguous requirements, edge cases without clear guidance, or apparent contradictions, stop and request clarification rather than interpreting.
- Preserve institutional knowledge. When you encounter implicit business rules, policy interpretations, or undocumented edge cases in existing code, extract them into specification language for human verification.
- Specifications are located in
specifications/(adjust path as needed for your project) - Each specification documents what the system should do, independent of implementation
- Specifications include requirements, acceptance criteria, edge cases, and references to governing rules (statutes, regulations, policies)
Specifications in this project follow this structure:
# [Feature/Component Name] Specification
## Purpose
Brief description of what this component does and why it exists.
## Requirements
### Requirement: [Requirement Name]
The system SHALL [behavior description].
#### Acceptance Criteria
- GIVEN [precondition]
- WHEN [action]
- THEN [expected outcome]
#### Edge Cases
- [Edge case description and expected handling]
## References
- [Link to governing statute, regulation, or policy]
- [Link to related specifications]When proposing specification changes:
- Document the change clearly. Show what is being added, modified, or removed.
- Explain the rationale. Why is this change needed? What requirement, bug, or policy change drives it?
- Identify affected code. List components that will need implementation changes.
- Request human review. Specification changes require domain expert approval before implementation proceeds.
- Identify the governing specification for the feature
- Confirm the specification covers the behavior you're implementing
- If not covered, draft a specification update first
- Reference specification requirements in code comments where helpful
- Name functions, variables, and modules to align with specification terminology
- Implement exactly what the specification requires—no more, no less
- Verify implementation matches all acceptance criteria
- Document any implementation decisions that aren't obvious from the spec
- If implementation revealed spec gaps, note them for future spec updates
When analyzing existing code to generate specifications:
- Identify business logic. Distinguish business rules from infrastructure, error handling, and technical implementation details.
- Trace to authoritative sources. Look for references to statutes, regulations, form numbers, or policy documents in comments or naming.
- Document edge cases. Pay special attention to conditional logic, boundary conditions, and error handling—these often encode important business rules.
- Preserve original intent. Capture what the code does, not what you think it should do. Specification review will determine correctness.
Generate specifications that:
- Use plain language a domain expert can verify
- Include all requirements with acceptance criteria
- Document edge cases and boundary conditions
- Reference governing rules (IRC sections, regulations, policies)
- Note any ambiguities or areas needing clarification
- Contradictory logic paths
- Undocumented magic numbers or thresholds
- Business rules with no apparent authoritative source
- Dead code that may represent deprecated requirements
- Assumptions you made during analysis
- Primary specification:
docs/SPECIFICATION.md - Test plan (derived from specification):
docs/TESTPLAN.md - Legacy COBOL code (for analysis only):
src/cobol/
- This system implements a school accounting system for managing student accounts
- Operations include: viewing balance, crediting accounts, debiting accounts
- Key business rule: Debits cannot exceed current balance
- The specification is the authoritative source of truth for system behavior
- The Node.js implementation in
src/accounting/implements the specification - Test files reference scenarios from
docs/TESTPLAN.md
- Specification changes trigger automatic issue creation via the SpecOps GitHub Action
- Use label
spec-changefor specification-related work - Implementation PRs must reference the governing specification
When developing or implementing CI/CD workflows for this project, consider adding automation to enforce the SpecOps methodology:
The SpecOps GitHub Action automatically creates issues when specification files are modified, ensuring that spec changes generate trackable work items for implementation review.
- uses: spec-ops-method/spec-ops-action@v1
with:
file-pattern: 'specifications/**/*.md'
labels: 'spec-change'This reinforces the spec-first workflow by:
- Creating an issue for each specification change with the diff
- Making spec changes visible and trackable
- Ensuring implementation work flows from documented spec changes
If the GitHub Action doesn't fit your workflow, consider other mechanisms that enforce the same principle—spec changes should generate visible, trackable work items:
- Branch protection rules requiring spec review
- Custom CI checks that flag code changes without corresponding spec updates
- PR templates that prompt for specification references
The goal is ensuring that specification changes don't get lost and that implementation follows documented requirements.
This project may include reusable AI agent instruction sets (skills) for specific domains:
- Skills are located in
skills/(if present) - Load relevant skills before working on domain-specific tasks
- Skills extend these base instructions with specialized knowledge