assets/skills/sync-docs/SKILL.md
Sync documentation workflow - reads codebase and docs folder to generate structured output docs with architecture, use cases, diagrams, and README index. Includes automated review loop. Use when user says "sync docs", "sync documentation", "generate docs", "update docs sync", "doc sync".
npx skillsauth add phuthuycoding/moicle sync-docsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Automated workflow that reads codebase and existing docs to generate a complete, structured documentation output with architecture overview, use case diagrams, and a README index linking all sub-files.
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ 1. SCAN │──▶│1.5 CONFIRM──▶│2. GENERATE──▶│ 3. REVIEW │──▶│4. COMPLETE│
└──────────┘ └──────────┘ └──────────┘ └──────────┘ └──────────┘
▲ │
│ Feedback │
└──────────────┘
(loop until pass)
Key: Phase 1.5 CONFIRM asks user to choose between REFACTOR (full restructure) or UPDATE (keep structure, update & link only). Phase 3 REVIEW automatically loops back to Phase 2 GENERATE if issues are found.
Goal: Read and understand the entire codebase and existing docs
Identify project stack:
package.json, go.mod, pubspec.yaml, composer.json, etc.Read existing documentation:
# Find all doc files
find . -name "*.md" -not -path "*/node_modules/*" -not -path "*/vendor/*" -not -path "*/.dart_tool/*" | sort
# Find existing docs folder
ls -la docs/ 2>/dev/null
Map codebase structure:
# Get directory tree (exclude build artifacts)
tree -L 4 -I 'node_modules|vendor|dist|build|.dart_tool|.git' --dirsfirst
Identify key components:
Extract use cases from the codebase:
Read architecture files (if exist):
ls .claude/architecture/*.md 2>/dev/null
ls ~/.claude/architecture/*.md 2>/dev/null
## Scan Results
### Stack: [identified stack]
### Architecture: [identified pattern]
### Existing Docs
- [list of existing .md files and their status]
### Identified Use Cases
1. [Use Case 1] - [brief description]
2. [Use Case 2] - [brief description]
3. [Use Case N] - [brief description]
### Key Components
- Entry Points: [list]
- Business Logic: [list]
- Data Layer: [list]
- Config: [list]
### Docs Output Plan
- docs/README.md (index)
- docs/business.md (business overview - non-technical, business language only)
- docs/architecture.md
- docs/use-cases/[usecase-name].md (per use case)
- docs/diagrams/ (embedded in use case files via mermaid)
Goal: Ask the user how they want to handle docs before generating.
Present scan results from Phase 1 to the user (current structure, identified use cases, docs plan)
Ask the user:
How would you like to proceed with the docs?
1. Refactor - Restructure docs into the standard template (docs/README.md, business.md, architecture.md, use-cases/) and relink everything
2. Update & Link only - Keep the current docs structure as-is, only update content and fix linking
(Choose 1 or 2)
Based on the choice, set the mode for Phase 2:
Goal: Generate all documentation files based on the selected mode from Phase 1.5
The templates below apply fully to REFACTOR mode. For UPDATE mode, use them as content/format reference only — do NOT force the structure.
docs/
├── README.md # Index - links to all sub-files
├── business.md # Business overview - non-technical, business language only
├── architecture.md # Architecture overview + system diagram
└── use-cases/
├── [use-case-1].md # Use case doc + sequence diagram
├── [use-case-2].md # Use case doc + sequence diagram
└── [use-case-N].md # Use case doc + sequence diagram
docs/README.md (Index)# [Project Name] Documentation
> Auto-generated documentation synced from codebase.
## Overview
[1-2 paragraph project description derived from codebase]
## Table of Contents
### Business
- [Business Overview](./business.md) - Business overview, goals, target users
### Architecture
- [Architecture Overview](./architecture.md) - System architecture, layers, and patterns
### Use Cases
- [Use Case 1](./use-cases/use-case-1.md) - [brief description]
- [Use Case 2](./use-cases/use-case-2.md) - [brief description]
- [Use Case N](./use-cases/use-case-n.md) - [brief description]
## Tech Stack
| Component | Technology |
|-----------|-----------|
| Language | [language] |
| Framework | [framework] |
| Database | [database] |
| Other | [key deps] |
## Quick Links
- [Business Overview](./business.md)
- [Architecture Diagram](./architecture.md#system-diagram)
- [Use Case Diagrams](./use-cases/)
docs/business.md (Business Overview)This file is written entirely in business language. NO code, NO class/function names, NO technical jargon. Target audience: stakeholders, product owners, business analysts - people who don't need to know the code.
# [Project Name] - Business Overview
## What is this product?
[2-3 paragraphs describing the product in everyday language. Explain what problem it solves, for whom, and why it's needed.]
## Target Users
### [Role 1] - e.g., End User
- **Who**: [description]
- **Needs**: [what they need from the product]
- **What they do**: [key actions on the system]
### [Role 2] - e.g., Administrator
- **Who**: [description]
- **Needs**: [what they need]
- **What they do**: [key actions on the system]
## Core Business Processes
### [Process 1] - e.g., Registration and first-time use
[Describe each step from the user's perspective. No mention of API, database, or any technical details.]
1. [Step 1 - what the user does]
2. [Step 2 - how the system responds]
3. [Step N]
### [Process 2] - e.g., Placing an order
[Same approach - describe from a business perspective]
## Key Features
| Feature | Description | Used by |
|---------|-------------|---------|
| [Feature 1] | [explain in business language] | [role] |
| [Feature 2] | [explain] | [role] |
## Business Rules
Key rules the system follows:
1. **[Rule 1]**: [explain - e.g., "Every order must contain at least 1 product"]
2. **[Rule 2]**: [explain - e.g., "Users can only request a refund within 7 days"]
3. **[Rule N]**: [explain]
## Business Entity Relationships
[Describe key relationships in plain text, e.g.:]
- A **customer** can create multiple **orders**
- An **order** contains multiple **products**
- A **product** belongs to a **category**
## Value Flow
[Describe how the product creates value for each stakeholder:]
- **For [role 1]**: [value they receive]
- **For [role 2]**: [value they receive]
- **For the business**: [value the business receives]
## Business Glossary
| Term | Definition |
|------|-----------|
| [Term 1] | [explain in the product's context] |
| [Term 2] | [explain] |
IMPORTANT rules for business.md:
docs/architecture.md (Technical)# Architecture Overview
## System Diagram
\`\`\`mermaid
graph TB
[Generate actual system architecture diagram based on codebase layers]
\`\`\`
## Layers
### [Layer 1 Name]
- **Location**: `[directory path]`
- **Responsibility**: [what this layer does]
- **Key Files**: [list important files]
### [Layer 2 Name]
[same structure]
## Directory Structure
\`\`\`
[actual project directory tree with annotations]
\`\`\`
## Dependencies Between Layers
\`\`\`mermaid
graph LR
[Show dependency direction between layers]
\`\`\`
## Design Patterns Used
- [Pattern 1]: [where and why]
- [Pattern 2]: [where and why]
## Data Flow
\`\`\`mermaid
flowchart LR
[Show how data flows through the system]
\`\`\`
docs/use-cases/[name].md)Generate ONE file per use case:
# [Use Case Name]
## Overview
[Description of what this use case does from user perspective]
## Actors
- [Actor 1]: [role]
- [Actor 2]: [role]
## Flow
### Main Flow
1. [Step 1]
2. [Step 2]
3. [Step N]
### Sequence Diagram
\`\`\`mermaid
sequenceDiagram
participant [Actor]
participant [Component1]
participant [Component2]
participant [DataStore]
[Actor]->>[Component1]: [action]
[Component1]->>[Component2]: [action]
[Component2]->>[DataStore]: [action]
[DataStore]-->>[Component2]: [response]
[Component2]-->>[Component1]: [response]
[Component1]-->>[Actor]: [response]
\`\`\`
## Related Files
| File | Purpose |
|------|---------|
| `[path/to/file]` | [what it does in this use case] |
| `[path/to/file]` | [what it does in this use case] |
## Error Cases
| Error | Cause | Handling |
|-------|-------|----------|
| [Error 1] | [cause] | [how handled] |
## Notes
- [Any important implementation details]
Goal: Verify generated docs are complete and accurate. Loop back to GENERATE if issues found.
Run through ALL checks below. If ANY check fails, fix and re-check.
docs/README.md exists and has all linksdocs/business.md existsdocs/architecture.md exists with system diagramdocs/use-cases/docs/business.md contains NO technical jargon (API, endpoint, database, repository, controller, service, model, schema, query, migration, route, middleware, component, module, class, function, method, interface, type)docs/business.md has NO code blocksdocs/business.md does NOT reference file paths[TODO], [TBD], [placeholder]{name}, [name] left unfilledFOR each check in checklist:
IF check FAILS:
1. Note the issue
2. Fix it (go back to relevant GENERATE sub-step)
3. Re-run ALL checks from the beginning
IF all checks PASS:
Proceed to Phase 4
## Review Results - Iteration [N]
### Checks Passed: [X/total]
### Checks Failed: [Y/total]
### Issues Found
1. [issue] → [fix applied]
2. [issue] → [fix applied]
### Status: [PASS - proceed to Phase 4 / FAIL - re-running Phase 2]
IMPORTANT: Do NOT proceed to Phase 4 until ALL checks pass. Maximum 3 iterations - if still failing after 3 loops, report remaining issues and proceed.
Goal: Final output and summary
List all generated files:
find docs/ -name "*.md" | sort
Print summary:
## Sync Docs Complete
### Generated Files
- docs/README.md (index)
- docs/business.md (business overview)
- docs/architecture.md
- docs/use-cases/[list all]
### Use Cases Documented: [count]
### Diagrams Generated: [count]
### Review Iterations: [count]
### How to Use
Start at `docs/README.md` - it links to everything.
Read the docs/ folder one final time to confirm everything is in order
| Phase | Agent | Purpose |
|-------|-------|---------|
| SCAN | @clean-architect | Identify architecture patterns |
| SCAN | @code-reviewer | Understand code structure |
| GENERATE | @docs-writer | Write documentation |
| REVIEW | @code-reviewer | Verify accuracy |
docs/
├── README.md # Index with links
├── business.md # Business overview (non-technical)
├── architecture.md # System overview + diagram
└── use-cases/
└── *.md # One per use case + sequence diagram
| Where | Diagram Type | Purpose |
|-------|-------------|---------|
| architecture.md | graph TB | System architecture |
| architecture.md | graph LR | Layer dependencies |
| architecture.md | flowchart LR | Data flow |
| use-cases/*.md | sequenceDiagram | Use case flow |
Scan → Confirm (Refactor/Update?) → Generate → Review → Pass? → Complete
→ Fail? → Fix → Review again (max 3x)
Documentation sync is complete when:
development
Test-Driven Development workflow. Use when doing TDD, writing tests first, or when user says "tdd", "test first", "test driven", "red green refactor".
development
Thorough pull request review workflow with architecture compliance checks. Use when reviewing pull requests, checking code changes, or when user says "review pr", "check pr", "review code", "pr review", "review pull request".
development
Review local branch changes for architecture compliance, conventions, and code quality before pushing/PR. Stack-aware — detects the project stack and applies the matching rules. Use when user says "review changes", "review branch", "check branch", "check changes", "review my code", "review before pr".
testing
DDD architecture compliance review with automated checks and review loop. Use when user says "architect-review", "architecture review", "review architecture", "check architecture", "review ddd", "ddd review".