"Code follows documentation" structure by writing **documentation drafts before implementation**. This is the documentation version of Test-Driven Development (TDD).
Writes documentation drafts before implementation to clarify design and ensure code follows documentation. Triggers after code implementation but before review, creating API specs, docstrings, and test scenarios that serve as blueprints for the actual code.
/plugin marketplace add binee108/nine-step-workflow-plugin/plugin install nine-step-workflow@lilylab-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
"Code follows documentation" structure by writing documentation drafts before implementation. This is the documentation version of Test-Driven Development (TDD).
<!-- CUSTOMIZE: Adjust language/localization preferences -->Old Approach (Problem):
Step 3: Write Code → Step 5: Write Documentation
Problem: Documentation after implementation → Intent distortion possible
Improved Approach (Solution):
Step 3.5: Write Documentation Draft → Step 4: Write Code
Benefit: Documentation serves as design → Code follows documentation
backend-developer or frontend-developer1. API Specification (Backend)
## API Endpoint: POST /api/{{RESOURCE_NAME}}/{{ACTION}}
### Purpose
{{Brief description of what this endpoint does and why}}
### Request
```json
{
"{{field1}}": "{{example_value}}",
"{{field2}}": {{example_number}}
}
{
"{{id_field}}": "{{example_id}}",
"status": "success",
"{{data_field}}": {{example_data}}
}
{
"error": "{{error_code}}",
"message": "{{error_description}}"
}
**2. Function Signature & Docstring**
<!-- Multi-language examples -->
**Python:**
```python
def {{function_name}}({{param1}}: {{Type1}}, {{param2}}: {{Type2}} = {{default}}) -> {{ReturnType}}:
"""
{{Brief description of function purpose}}.
WHY: {{Explain why this function exists and what problem it solves}}
Args:
{{param1}}: {{Description and constraints}}
{{param2}}: {{Description and default behavior}}
Returns:
{
"{{field1}}": {{Description}},
"{{field2}}": {{Description}}
}
Raises:
{{ExceptionType}}: {{When and why this exception is raised}}
Edge Cases:
- {{Edge case 1}}: {{How it's handled}}
- {{Edge case 2}}: {{How it's handled}}
Side Effects:
- {{Side effect 1}}
- {{Side effect 2}}
Performance:
- {{Performance characteristic 1}}
- {{Performance characteristic 2}}
Debugging Tips:
- {{Tip 1}}
- {{Tip 2}}
"""
# Implementation not yet written (draft stage)
pass
JavaScript/TypeScript:
/**
* {{Brief description of function purpose}}.
*
* WHY: {{Explain why this function exists}}
*
* @param {{param1}} - {{Description and constraints}}
* @param {{param2}} - {{Description and default behavior}}
* @returns {{Return value description}}
* @throws {{{ExceptionType}}} {{When and why}}
*
* Edge Cases:
* - {{Edge case 1}}: {{How handled}}
*
* Side Effects:
* - {{Side effect description}}
*
* Performance:
* - {{Performance notes}}
*/
function {{functionName}}({{param1}}: {{Type1}}, {{param2}}: {{Type2}} = {{default}}): {{ReturnType}} {
// Implementation not yet written (draft stage)
}
Go:
// {{FunctionName}} {{brief description}}.
//
// WHY: {{Explain purpose}}
//
// Parameters:
// - {{param1}}: {{Description}}
// - {{param2}}: {{Description}}
//
// Returns:
// - {{ReturnType}}: {{Description}}
// - error: {{Error conditions}}
//
// Edge Cases:
// - {{Edge case}}: {{Handling}}
//
// Side Effects:
// - {{Side effect}}
func {{FunctionName}}({{param1}} {{Type1}}, {{param2}} {{Type2}}) ({{ReturnType}}, error) {
// Implementation not yet written (draft stage)
return nil, nil
}
3. Core Logic Flow
## Core Logic Flow
1. Input Validation
- {{field1}}: {{validation rules}}
- {{field2}}: {{validation rules}}
2. {{Step 2 description}}
- {{Details}}
- {{Timeout/retry logic}}
3. {{Step 3 description}}
```json
{{Example payload}}
Data Storage/Processing
Response Generation
**4. Error Handling Strategy**
```markdown
## Error Scenarios
| Error Situation | HTTP Code | Response Message | Handling Method |
|----------------|-----------|------------------|-----------------|
| {{Error 1}} | {{4xx/5xx}} | "{{message}}" | {{Action}} |
| {{Error 2}} | {{4xx/5xx}} | "{{message}}" | {{Action}} |
| {{Error 3}} | {{4xx/5xx}} | "{{message}}" | {{Action}} |
5. Test Scenarios (Draft)
## Test Scenarios
### Happy Path
- ✅ {{Scenario 1}} → {{Expected result}}
- ✅ {{Scenario 2}} → {{Expected result}}
### Error Scenarios
- ❌ {{Error scenario 1}} → {{Expected exception}}
- ❌ {{Error scenario 2}} → {{Expected exception}}
### Edge Cases
- ✅ {{Edge case 1}} → {{Expected behavior}}
- ✅ {{Edge case 2}} → {{Expected behavior}}
Verification Example:
# Documentation draft (Step 3.5)
{{Example showing documentation}}
# Actual code (Step 4)
{{Example showing implementation}}
# ✅ Matches documentation
Draft → Final Documentation:
# Step 3.5 Draft
## Edge Cases
- {{Edge case}}: {{Expected handling}}
# Step 5 Final (After testing)
## Edge Cases
- {{Edge case}}: {{Expected handling}}
- ⚠️ Known Issue: {{Discovered issue}}
- Solution: {{Workaround}}
## Test Results
- Actual {{metric}}: {{actual_value}} (Expected: {{expected_value}})
Step 3: Code (backend-developer)
↓
Step 4: Code Review (code-reviewer)
↓
Step 5: Documentation (documentation-manager)
Step 3: Code Implementation (backend-developer)
↓
Step 3.5: Documentation Draft (backend-developer) ← New
↓
Step 4: Code Review (code-reviewer) ← Add consistency verification
↓
Step 5: Documentation Finalization (documentation-manager) ← Finalize from draft
Immediately execute Step 3.5 after Step 3 completion:
✅ Step 3 (Code Implementation) Complete
Now starting Step 3.5 (Documentation Draft).
Write the following documentation draft:
1. API specification (endpoints, request/response)
2. Function signature & Docstring (WHY, Args, Returns, Raises, Edge Cases)
3. Core logic flow
4. Error handling strategy
5. Test scenarios (draft)
Draft location: docs/drafts/{{feature-name}}_draft.md
Add to Step 4 review items:
## Code-Documentation Consistency
- [ ] API spec matches actual code?
- [ ] Docstring Args/Returns match signature?
- [ ] Defined exceptions exist in actual code?
- [ ] Edge case handling logic implemented?
- [ ] Error handling strategy followed?
If inconsistency found: NEEDS_REVISION (update docs or code)
Change Step 5 tasks:
Finalize documentation based on Step 3.5 draft.
**Draft location**: docs/drafts/{{feature-name}}_draft.md
**Final Documentation Tasks**:
1. Review draft and compare with actual implementation
2. Fix inconsistencies
3. Reflect test results (after Step 7 complete)
4. Update code examples
5. Add Known Issues
6. Update Feature Catalog
**Final location**: docs/features/{{feature-name}}.md
Step 3.5 Completion Criteria:
Step 4 Code-Documentation Consistency Criteria:
Step 5 Final Documentation Criteria:
Remember: "Documentation-First Development" like TDD clarifies design and reduces implementation errors. With a draft, code follows documentation.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.