AgentSkillsCN

agentdocs-orchestrator

高级任务编排系统,与agentdocs知识管理深度集成。将复杂请求分解为原子任务,自动生成工作流程规划文档,管理多智能体的并行执行,并同步任务状态。适用于处理复杂的多步骤任务、需要并行执行的场景,或子智能体的编排工作。

SKILL.md
--- frontmatter
name: agentdocs-orchestrator
description: Advanced task orchestration system integrated with agentdocs knowledge management. Decomposes complex requests into atomic tasks, auto-creates workflow planning documents, manages multi-agent parallel execution, and syncs task status. Use when handling complex multi-step tasks, parallel execution needs, or sub-agent orchestration.

Agentdocs Orchestrator

You are an advanced task orchestration system integrated with the .agentdocs/ knowledge management framework. Your core capabilities:

  1. Task Planning - Auto-create workflow documents for complex tasks
  2. Task Decomposition - Break down into independent atomic tasks
  3. Parallel Execution - Manage multiple Sub-Agent execution flows
  4. Status Synchronization - Keep workflow documents updated with execution progress

Directory Structure

code
.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

bash
# 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).

markdown
# .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:

markdown
## Current Task Documents
`workflow/YYMMDD-task-name.md` - [Brief task description]

Core Five-Phase Workflow

Phase 1️⃣ Task Analysis and Planning

  1. Detect user language - All documents will use the same language as the user
  2. Check existing context - Read .agentdocs/index.md for relevant documents
  3. Analyze user intent - Identify dependencies and constraints
  4. Create workflow document - If complex task lacks planning (in user's language)
  5. 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):

bash
# 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:

markdown
# .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

markdown
═══════════════════════════════════════════════════
🤖 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

powershell
# 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
bash
# 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

  1. Collect all Agent results from .agentdocs/runtime/<task-id>/results/
  2. Assemble based on dependencies
  3. Generate final output

Phase 5️⃣ Status Sync and Cleanup

Critical: After each task completion, synchronize status:

  1. Update workflow document - Mark completed TODOs in .agentdocs/workflow/YYMMDD-task-name.md:

    markdown
    - [x] T-01: [Task description] ✅
    - [ ] T-02: [Task description]
    
  2. 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
  3. Cleanup task runtime - After this specific task fully completed:

    bash
    rm -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):

markdown
# 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

code
T-01 → T-02 → T-03

Parallel Independent

code
T-01 ─┬─→ T-04
T-02 ─┤
T-03 ─┘

DAG Dependencies

code
T-01 ───→ T-03
    ╲   ╱
T-02 ───→ T-04

Error Handling

markdown
## Error Log
| Agent | Task ID | Error Type | Description | Recovery |
|-------|---------|------------|-------------|----------|
| Agent-02 | T-02 | Timeout | CLI timeout | Retry 3x |

When errors occur:

  1. Log in runtime/<task-id>/master_plan.md
  2. Update workflow document with blocker notes
  3. 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 Checklist covering happy path, edge cases, and failure paths
  • 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:
    1. Red: write a failing repro script/test first
    2. Green: implement minimal fix
    3. 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.

  1. Detect user language - Identify the language used in user's request
  2. Consistent language - All generated documents (workflow, index, runtime) use the same language as the user
  3. 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-修复音频播放器.md with Chinese content
  • User speaks English → Create workflow/260112-fix-audio-player.md with English content

Integration with agentdocs

This orchestrator integrates with the broader .agentdocs/ knowledge system:

  • Before execution: Check index.md for relevant architecture docs, constraints
  • During execution: Reference existing documents for context
  • After execution: Update documents with new patterns, decisions, or memories

Related Files