| name | speccrew-dev-backend |
| description | Backend Development SOP. Guide System Developer Agent to implement backend code according to system design documents. Reads design blueprints, extracts task checklist, and executes implementation task by task with local quality checks. |
| tools | Bash, Edit, Write, Glob, Grep, Read |
Trigger Scenarios
- Backend system design has been approved, user requests backend development
- User asks "Start backend development", "Implement backend code"
- System Developer Agent receives task to implement backend for a specific platform
Input Parameters
| Parameter | Required | Type | Description |
|---|
design_doc_path | Yes | string | Path to a single module design document (passed by upstream system-developer agent) |
platform_id | Yes | string | Platform identifier (e.g., backend-spring, backend-nodejs) |
task_id | Yes | string | Task identifier from dispatch context |
iteration_id | No | string | Current iteration identifier for progress messages |
output_dir | No | string | Output directory for task record (default: auto-derived from iteration path) |
AgentFlow Definition
REQUIRED: Before executing this workflow, read the XML workflow specification: speccrew-workspace/docs/rules/agentflow-spec.md
Workflow
Absolute Constraints
These rules apply to Task Record document generation. Violation = task failure.
-
FORBIDDEN: create_file for Task Record โ NEVER use create_file to write the Task Record document. It MUST be created by copying the template then filling sections with search_replace. create_file produces truncated output on large files.
-
FORBIDDEN: Full-file rewrite โ NEVER replace the entire Task Record content in a single operation. Always use targeted search_replace on specific sections.
-
MANDATORY: Template-first workflow โ Copy template MUST execute before fill sections. Skipping copy and writing content directly is FORBIDDEN.
-
CLARIFICATION: Source code is NOT template-filled โ Actual source code files are written directly based on design blueprints. The template-fill workflow applies ONLY to the Task Record document.
Step 1: Read Design Documents
Input: design_doc_path โ Path to a single module design document (passed by upstream system-developer agent).
Read in order:
- Module Design Document: The
design_doc_path provided (single module's design)
- Platform INDEX:
speccrew-workspace/iterations/{number}-{type}-{name}/03.system-design/{platform_id}/INDEX.md
- API Contract:
speccrew-workspace/iterations/{number}-{type}-{name}/03.api-contract/[feature-name]-api-contract.md
- Techs Knowledge (from agent context):
speccrew-workspace/knowledges/techs/{platform_id}/tech-stack.md
speccrew-workspace/knowledges/techs/{platform_id}/architecture.md
speccrew-workspace/knowledges/techs/{platform_id}/conventions-design.md
speccrew-workspace/knowledges/techs/{platform_id}/conventions-dev.md
speccrew-workspace/knowledges/techs/{platform_id}/conventions-data.md (critical: ORM, data modeling, migration)
- Task Record Template:
speccrew-dev-backend/templates/TASK-RECORD-TEMPLATE.md
Step 2: Create Task Record File
Before coding, create the task record using template-fill workflow:
2a Copy Template to Task Record Path
- Read the template file:
templates/TASK-RECORD-TEMPLATE.md
- Replace top-level placeholders (module name, feature name, platform ID, iteration info)
- Create the document using
create_file:
- Target path:
speccrew-workspace/iterations/{number}-{type}-{name}/04.development/{platform_id}/[module]-task.md
- Content: Template with top-level placeholders replaced
- Verify: Document has complete section structure ready for filling
2b Fill Task Record Sections Using search_replace
Fill each section with design metadata extracted from input documents.
โ ๏ธ CRITICAL CONSTRAINTS:
- FORBIDDEN:
create_file to rewrite the entire document
- MUST use
search_replace to fill each section individually
- All section titles MUST be preserved
Step 3: Extract Task List
Parse design documents to extract all implementation tasks.
Backend Task Types
| Category | Description | Example Files |
|---|
| Entity/Model | Data model definitions | entity/, model/, domain/ |
| Repository/DAO | Data access layer | repository/, dao/, mapper/ |
| Service | Business logic layer | service/, manager/, handler/ |
| Controller/API | REST endpoints | controller/, router/, api/ |
| Database Migration | Schema changes | db/migration/, migrations/ |
| API Configuration | Route/middleware config | config/, routes/ |
| Middleware/Interceptor | Cross-cutting concerns | middleware/, interceptor/ |
Task Checklist Table Format
| Task ID | Module | Description | Target Files | API Endpoint | DB Migration | Dependencies | Status |
|---|
| BE-001 | User | Define User entity | entity/User.java | - | V001__create_user.sql | - | โณ Pending |
| BE-002 | User | Create UserRepository | repository/UserRepository.java | - | - | BE-001 | โณ Pending |
| BE-003 | Auth | Login endpoint | controller/AuthController.java | POST /auth/login | - | BE-002 | โณ Pending |
Status: โณ Pending / ๐ In Progress / โ
Complete / ๐ซ Blocked
Proceed directly to implementation โ no user confirmation required.
Step 4: Task-by-Task Implementation
Execute tasks in dependency order.
Implementation Principles
- Follow design document file paths, naming, and structure exactly
- Use actual framework syntax from techs knowledge (not generic pseudo-code)
- Follow conventions-data.md for ORM patterns and migration naming
- Reuse existing code where possible (use Grep to search)
- Directly write code based on design blueprint (no template filling for source code)
Per-Task Workflow
- Mark task as ๐ In Progress
- Implement the code following design specification
- Run local checks (Step 6)
- Update status to โ
Complete if checks pass
- Record deviations if implementation differs from design
When Design Issues Found
- Stop current task
- Describe issue clearly to user
- Wait for user decision: return to design phase OR proceed with documented deviation
Step 5: Database Migration Verification
This step applies ONLY when the task checklist contains Database Migration tasks.
If no migration tasks exist, skip to Step 6.
5.1 Verify Migration Scripts
After all migration-related tasks in Step 4 are complete:
- Check script existence: Verify all migration scripts listed in the design document's "Migration Requirements" table have been created at the specified paths
- Check naming convention: Verify script names follow the pattern defined in conventions-data.md Migration Configuration
- Check script content: Each script must contain valid SQL/DDL (or tool-specific syntax) that matches the Table Schema defined in the design document
5.2 Verify Migration Order
- Dependency check: Migration scripts with table dependencies must be ordered correctly (e.g., referenced table created before foreign key table)
- Version sequence: Migration version numbers must be sequential with no gaps
5.3 Report Migration Summary
Add to the task record:
| Script Name | Path | Type | Tables Affected | Status |
|---|
| {name} | {path} | CREATE/ALTER | {tables} | Created/Verified |
Step 6: Local Checks
After completing each task, run quality checks:
Check Matrix
| Check | Command Example | When Required |
|---|
| Compile | mvn compile / gradle build / go build | After code changes |
| Lint | mvn checkstyle:check / golangci-lint run | After code changes |
| Unit Tests | mvn test -Dtest=XxxTest / go test ./... | When testable logic added |
| API Smoke Test | Start service, curl http://localhost:8080/health | After controller changes |
Check Failure Handling
- Fix issues before marking task complete
- For complex issues, record in task file "Pending Issues" section
- Do NOT proceed to next task until current task passes checks
Environment Diagnostics
When task is blocked (compile fail, test fail, env issue):
- Check logs:
docker logs [container] --tail 100 or process output
- Verify services:
docker ps / docker compose ps
- Check environment:
.env variables, database connectivity
- Record diagnosis: symptom โ investigation steps โ root cause โ resolution
Step 7: Record Deviations
If implementation differs from design, record in task file "Deviation Log" section:
### Deviation Log
| Task ID | Design Spec | Actual Implementation | Reason |
|---------|-------------|----------------------|--------|
| BE-003 | Use JWT library A | Used JWT library B | Library A has security vulnerability |
Step 8: Handle Technical Debt
If accepting suboptimal solutions, write to tech-debt directory:
Path: speccrew-workspace/iterations/{number}-{type}-{name}/tech-debt/[module]-tech-debt.md
Use the unified tech_debt document template defined in the workspace document templates configuration.
Helper Scripts Output
All temporary/helper scripts (validation, data init, environment setup, etc.) MUST be saved to:
iterations/{iter}/04.development/{platform_id}/scripts/
Exception: Application source scripts (migrations, seeds) go to the project source directory per conventions-data.md.
Include all generated scripts in the Task Record "Generated Scripts" section with path and purpose.
Step 9: Completion Notification
When all tasks complete, update task record and notify user:
Backend Development Complete: {module-name}
Platform: {platform_id}
Tasks Completed: {X}
โโโ โ
Complete: {count}
โโโ ๐ซ Blocked: {count}
โโโ Deviations: {count}
API Endpoints:
โโโ Implemented: {count} endpoints
โโโ Status: See task record for details
Database Changes:
โโโ New Tables: {count}
โโโ Modified Tables: {count}
โโโ Migrations: {count}
Technical Debt: {count} items (see tech-debt/)
Task Record: speccrew-workspace/iterations/{number}-{type}-{name}/04.development/{platform_id}/[module]-task.md
Ready for testing phase.
Task Completion Report
At the end of Step 9 (or if the skill fails at any point), output a structured Task Completion Report:
Success Report
## Task Completion Report
- **Status**: SUCCESS
- **Task ID**: {task_id from dispatch context}
- **Platform**: {platform_id}
- **Module**: {module_name}
- **Output Files**:
- {file_path_1}
- {file_path_2}
- ...
- **Migration Scripts**: {count} scripts at {migration_dir}
- {script_1_name}: {type} ({tables})
- {script_2_name}: {type} ({tables})
- **Summary**: Backend module {module_name} implemented with {X} tasks completed
Failure Report
If the skill fails at any step:
## Task Completion Report
- **Status**: FAILED
- **Task ID**: {task_id from dispatch context}
- **Platform**: {platform_id}
- **Module**: {module_name}
- **Output Files**: {list of partially generated files, or "None"}
- **Summary**: {one-line description of what was attempted}
- **Error**: {detailed error description}
- **Error Category**: {DEPENDENCY_MISSING | BUILD_FAILURE | VALIDATION_ERROR | RUNTIME_ERROR | BLOCKED}
- **Partial Outputs**: {list of files that were generated before failure, or "None"}
- **Recovery Hint**: {suggestion for how to resolve and retry}
Error Category Definitions:
DEPENDENCY_MISSING: Required runtime/dependency not available
BUILD_FAILURE: Compilation error, maven/gradle build failure
VALIDATION_ERROR: Checkstyle, test failure, or validation error
RUNTIME_ERROR: Service startup failure, runtime exception
BLOCKED: Blocked by external dependency or unresolved design issue
OUTPUT EFFICIENCY RULES
When executing this skill:
- Direct-to-File Output: All implementation code, task records, and helper scripts MUST be written directly to output files
- Minimal Conversation Output: Only output:
- Block execution announcements (1 line each):
"[Block XX] Implementing..."
- Error messages requiring attention
- Task Completion Report (final summary)
- FORBIDDEN in conversation:
- โ Full source code blocks or file contents
- โ Complete implementation listings
- โ Large configuration file dumps
- โ Architecture diagrams displayed in chat
- โ API endpoint listings longer than 3 lines
- Rationale: Workers run in batch mode (up to 6 concurrent). Displaying code content in conversation wastes context window and provides no value since content goes to files anyway.
ABORT CONDITIONS
When script execution or build/compile fails:
- STOP immediately โ Report: Task ID, error message, failed command
- FORBIDDEN responses on failure:
- โ DO NOT provide A/B/C alternative options
- โ DO NOT suggest "skip this step and continue"
- โ DO NOT run ad-hoc PowerShell/Bash commands as workaround
- โ DO NOT create temporary scripts to work around the issue
- ONLY correct response: Report the failure in Task Completion Report with status FAILED and error details
OUTPUT EFFICIENCY RULES
When executing this skill:
- Direct-to-File Output: All implementation code, task records, and helper scripts MUST be written directly to output files
- Minimal Conversation Output: Only output:
- Block execution announcements (1 line each):
"[Block XX] Implementing..."
- Error messages requiring attention
- Task Completion Report (final summary)
- FORBIDDEN in conversation:
- โ Full source code blocks or file contents
- โ Complete implementation listings
- โ Large configuration file dumps
- โ Architecture diagrams displayed in chat
- โ API endpoint listings longer than 3 lines
- Rationale: Workers run in batch mode (up to 6 concurrent). Displaying code content in conversation wastes context window and provides no value since content goes to files anyway.
ABORT CONDITIONS
When script execution or build/compile fails:
- STOP immediately โ Report: Task ID, error message, failed command
- FORBIDDEN responses on failure:
- โ DO NOT provide A/B/C alternative options
- โ DO NOT suggest "skip this step and continue"
- โ DO NOT run ad-hoc PowerShell/Bash commands as workaround
- โ DO NOT create temporary scripts to work around the issue
- ONLY correct response: Report the failure in Task Completion Report with status FAILED and error details
Key Rules
| Rule | Description |
|---|
| Blueprint-Driven | Implement directly from system design, no template filling for source code |
| Actual Framework Syntax | Use real framework annotations/syntax from techs knowledge |
| API Contract is READ-ONLY | Do NOT modify API Contract; report issues if found |
| Task List Required | Must extract and record task list before implementation |
| Per-Task Quality Gates | Each task must pass local checks before proceeding |
| Deviation Recording | ALL deviations from design must be documented |
| Tech Debt Tracking | Suboptimal solutions written to tech-debt/ directory |
Reference Guides
Mermaid Diagram Requirements
When generating Mermaid diagrams, follow compatibility guidelines:
- Use only basic node definitions:
A[text content]
- No HTML tags (e.g.,
<br/>)
- No nested subgraphs
- No
direction keyword
- No
style definitions
- No special characters in node text
- Use standard
graph TB/LR or flowchart TD/LR or erDiagram syntax only
Checklist