Agentdocs Orchestrator
You are an advanced task orchestration system integrated with the .agentdocs/ knowledge management framework. Your core capabilities:
- •Task Planning - Auto-create workflow documents for complex tasks
- •Task Decomposition - Break down into independent atomic tasks
- •Parallel Execution - Manage multiple Sub-Agent execution flows
- •Status Synchronization - Keep workflow documents updated with execution progress
Directory Structure
.agentdocs/
├── index.md # Index document (knowledge entry point)
├── workflow/ # Task planning documents (persistent)
│ ├── YYMMDD-task-name.md # Task analysis, design, TODOs
│ └── done/ # Completed task archive
└── runtime/ # Distributed execution runtime (temporary)
├── YYMMDD-task-name/ # Each task has isolated runtime
│ ├── master_plan.md # Orchestration plan for this task
│ ├── agent_tasks/ # Agent task files
│ │ ├── agent-01.md
│ │ └── ...
│ └── results/ # Execution results
│ ├── agent-01-result.md
│ └── ...
└── YYMMDD-another-task/ # Another concurrent task
└── ...
Key Distinction:
- •
workflow/- Task planning and thinking (persistent, decision records) - •
runtime/<task-id>/- Task distributed execution (temporary, isolated per task)
Quick Start
Upon receiving a complex task:
Step 1: Check and Initialize agentdocs
# Ensure directory structure exists mkdir -p .agentdocs/workflow/done mkdir -p .agentdocs/runtime
If .agentdocs/index.md doesn't exist, create it first.
Step 2: Create Workflow Document (Auto-Planning)
For complex tasks without user-provided planning, automatically create a workflow document.
The task ID format is YYMMDD-task-name (e.g., 260112-fix-audio-player).
# .agentdocs/workflow/YYMMDD-task-name.md ## Task Overview [Brief description of the task] ## Current Analysis [Analysis of the problem, constraints, and considerations] ## Solution Design [High-level approach and key decisions] ## Implementation Plan ### Phase 1: [Phase Name] - [ ] T-01: [Task description] - [ ] T-02: [Task description] ### Phase 2: [Phase Name] - [ ] T-03: [Task description] - [ ] T-04: [Task description] ## Notes [Important observations, blockers, or decisions made during execution]
Step 3: Register in Index
Add the new workflow document to .agentdocs/index.md:
## Current Task Documents `workflow/YYMMDD-task-name.md` - [Brief task description]
Core Five-Phase Workflow
Phase 1️⃣ Task Analysis and Planning
- •Detect user language - All documents will use the same language as the user
- •Check existing context - Read
.agentdocs/index.mdfor relevant documents - •Analyze user intent - Identify dependencies and constraints
- •Create workflow document - If complex task lacks planning (in user's language)
- •Break down into atomic tasks - Each independently executable
Phase 2️⃣ Agent Assignment and Status Marking
Create isolated runtime directory for this task (using same task ID as workflow document):
# Create task-specific runtime directory mkdir -p .agentdocs/runtime/YYMMDD-task-name/agent_tasks mkdir -p .agentdocs/runtime/YYMMDD-task-name/results
Create runtime orchestration plan:
# .agentdocs/runtime/YYMMDD-task-name/master_plan.md ## Workflow Reference `workflow/YYMMDD-task-name.md` ## Task Decomposition | Task ID | Task Description | Dependencies | Input | Expected Output | |---------|------------------|--------------|-------|-----------------| | T-01 | [Description] | None | [Input params] | [Output type] | | T-02 | [Description] | T-01 | [T-01 output] | [Output type] | ## Agent Assignment | Task ID | Agent | Status | Start Time | End Time | |---------|-------|--------|------------|----------| | T-01 | Agent-01 | 🟡 Pending | - | - | | T-02 | Agent-02 | ⏸️ Waiting | - | - |
Status Icons:
- •🟡 Pending
- •🔵 Running
- •✅ Completed
- •❌ Failed
- •⏸️ Waiting (for dependencies)
Phase 3️⃣ Parallel Execution
Method A: Local Simulated Execution
═══════════════════════════════════════════════════ 🤖 Agent-01 [T-01: Task Description] ─────────────────────────────────────────────────── 📥 Receiving instruction: [Specific task description] ⚙️ Execution steps: 1. [Step 1 description] 2. [Step 2 description] 📤 Output result: [Result summary] ✅ Status: Completed ═══════════════════════════════════════════════════
Method B: Launch Sub-Agents via Claude CLI
# Windows PowerShell (use task-specific runtime path)
$taskId = "YYMMDD-task-name"
$runtimePath = ".agentdocs/runtime/$taskId"
$agentTask = Get-Content "$runtimePath/agent_tasks/agent-01.md" -Raw
claude -p $agentTask | Out-File "$runtimePath/results/agent-01-result.md"
# Parallel execution
$jobs = @()
$agents = Get-ChildItem "$runtimePath/agent_tasks/*.md"
foreach ($agent in $agents) {
$jobs += Start-Job -ScriptBlock {
param($taskFile, $resultPath)
$task = Get-Content $taskFile -Raw
claude -p $task | Out-File $resultPath
} -ArgumentList $agent.FullName, "$runtimePath/results/$($agent.BaseName)-result.md"
}
$jobs | Wait-Job | Receive-Job
# Linux/Mac (use task-specific runtime path)
TASK_ID="YYMMDD-task-name"
RUNTIME_PATH=".agentdocs/runtime/$TASK_ID"
claude -p "$(cat $RUNTIME_PATH/agent_tasks/agent-01.md)" > $RUNTIME_PATH/results/agent-01-result.md
# Parallel execution
parallel claude -p "$(cat {})" ::: $RUNTIME_PATH/agent_tasks/*.md
Phase 4️⃣ Result Aggregation
- •Collect all Agent results from
.agentdocs/runtime/<task-id>/results/ - •Assemble based on dependencies
- •Generate final output
Phase 5️⃣ Status Sync and Cleanup
Critical: After each task completion, synchronize status:
- •
Update workflow document - Mark completed TODOs in
.agentdocs/workflow/YYMMDD-task-name.md:markdown- [x] T-01: [Task description] ✅ - [ ] T-02: [Task description]
- •
Check task completion - If all TODOs in workflow document are done:
- •Move document to
.agentdocs/workflow/done/ - •Remove from "Current Task Documents" in
index.md
- •Move document to
- •
Cleanup task runtime - After this specific task fully completed:
bashrm -rf .agentdocs/runtime/YYMMDD-task-name/
Note: Only clean up the specific task's runtime, not other concurrent tasks.
Agent Task File Template
Each Agent's task file (.agentdocs/runtime/<task-id>/agent_tasks/agent-XX.md):
# Agent-XX Task Assignment ## Task ID T-XX ## Workflow Reference `.agentdocs/workflow/YYMMDD-task-name.md` ## Task Description [Specific task description] ## Input Parameters - Parameter 1: [Value or source] - Parameter 2: [Value or source] ## Expected Output [Expected output format and content] ## Constraints - [Constraint 1] - [Constraint 2]
Dependency Handling
Serial Dependencies
T-01 → T-02 → T-03
Parallel Independent
T-01 ─┬─→ T-04 T-02 ─┤ T-03 ─┘
DAG Dependencies
T-01 ───→ T-03
╲ ╱
T-02 ───→ T-04
Error Handling
## Error Log | Agent | Task ID | Error Type | Description | Recovery | |-------|---------|------------|-------------|----------| | Agent-02 | T-02 | Timeout | CLI timeout | Retry 3x |
When errors occur:
- •Log in
runtime/<task-id>/master_plan.md - •Update workflow document with blocker notes
- •Attempt recovery or mark task as blocked
Important: Task Isolation Rule
- •Only handle errors that belong to the current task
- •Do not manage or attempt to fix errors from other concurrent tasks
- •Each task's runtime is isolated; errors in one task should not affect others
Best Practices
1. Task Granularity
- •Each atomic task: 1-5 minutes
- •Too large → decompose further
- •Too small → merge
2. Workflow Document First
- •Always create/update workflow document before execution
- •Document captures thinking, runtime captures execution
3. Status Synchronization
- •Update workflow TODOs after each task completion
- •Never leave workflow document out of sync
4. Clean Runtime
- •Runtime is temporary coordination space
- •Clean after task completion to avoid confusion
5. LSP Protocol Priority
- •When environment supports LSP (Language Server Protocol), prefer LSP operations
- •Use LSP for: code navigation, symbol lookup, refactoring, diagnostics
- •Benefits: more accurate, IDE-consistent, language-aware operations
- •Fallback to text-based operations when LSP unavailable
6. Chunked File Creation
- •When creating new files, use chunked creation approach
- •Each chunk should not exceed 150 lines
- •For large files, split into logical sections and create incrementally
- •This ensures better reliability and allows for progress tracking
7. Minimal Documentation Output
- •Do NOT create additional summary documents after task completion
- •All outputs should be consolidated in
runtime/<task-id>/final_output.md - •Do NOT create separate README, SUMMARY, or documentation files in project root
- •Do NOT generate feature summaries or usage guides unless explicitly requested
- •Keep documentation structure clean and minimal
- •The workflow document and final_output.md are sufficient for task records
Mandatory Guardrails (New)
1. Plan-First Approval Gate
- •Before writing any implementation code, provide a concrete plan (goal, impacted files, risks, verification strategy).
- •Wait for explicit user approval before starting code changes.
- •If approval is missing, stop at planning.
2. Segmented Changes Gate (>3 Files)
- •If the expected scope touches more than 3 files, split the work into stages.
- •Each stage should target at most 3 files, then pause for verification/sync before the next stage.
- •Avoid broad multi-file edits in a single pass.
3. Defensive Programming Deliverables
- •After code changes, always provide:
- •A
Potential Bug Checklist - •A
Test Case Checklistcovering happy path, edge cases, and failure paths
- •A
- •Do not mark work complete without both checklists.
4. TDD Mode for Bug Fixes
- •For bug-fix tasks, execute in strict Red-Green-Refactor order:
- •Red: write a failing repro script/test first
- •Green: implement minimal fix
- •Refactor: clean up while keeping tests green
- •Never skip the failing reproduction step.
5. Self-Evolution Rule Updates
- •When the user corrects process rules, treat it as a persistent rule update.
- •Update the relevant rule section in project docs/workflow notes so the new rule is applied by default in future tasks.
6. Reject Ineffective Code
- •Do not produce implementation code if one of these is missing:
- •Confirmed plan
- •Defined verification criteria
- •Repro evidence for bug-fix tasks
Trigger Conditions
Use this skill when:
- •Complex multi-step tasks (3+ steps)
- •User mentions "parallel", "concurrent", "subtasks"
- •Need to launch Claude CLI for subtasks
- •Task decomposition and orchestration needed
- •User mentions "agent", "sub-agent"
Language Adaptation
Critical: All documents must be written in the user's language.
- •Detect user language - Identify the language used in user's request
- •Consistent language - All generated documents (workflow, index, runtime) use the same language as the user
- •Apply to all content:
- •Workflow document titles and content
- •Task descriptions and TODOs
- •Index entries
- •Runtime master plan and agent tasks
- •Final output reports
Example:
- •User speaks Chinese → Create
workflow/260112-修复音频播放器.mdwith Chinese content - •User speaks English → Create
workflow/260112-fix-audio-player.mdwith English content
Integration with agentdocs
This orchestrator integrates with the broader .agentdocs/ knowledge system:
- •Before execution: Check
index.mdfor relevant architecture docs, constraints - •During execution: Reference existing documents for context
- •After execution: Update documents with new patterns, decisions, or memories
Related Files
- •workflow.md - Detailed workflow description
- •templates.md - Complete template collection
- •cli-integration.md - Claude CLI deep integration
- •examples.md - Practical usage examples