$npx -y skills add NeoLabHQ/context-engineering-kit --skill create-workflow-commandCreate a workflow command that orchestrates multi-step execution through sub-agents with file-based task prompts
| 1 | # Create Workflow Command |
| 2 | |
| 3 | Create a command that orchestrates multi-step workflows by dispatching sub-agents with task-specific instructions stored in separate files. |
| 4 | |
| 5 | ## User Input |
| 6 | |
| 7 | ```text |
| 8 | Workflow Name: $1 |
| 9 | Description: $2 |
| 10 | ``` |
| 11 | |
| 12 | ## Architecture Overview |
| 13 | |
| 14 | Workflow commands solve the **context bloat problem**: instead of embedding detailed step instructions in the main command (polluting orchestrator context), store them in separate task files that sub-agents read on-demand. |
| 15 | |
| 16 | ``` |
| 17 | plugins/<plugin-name>/ |
| 18 | ├── commands/ |
| 19 | │ └── <workflow>.md # Lean orchestrator (~50-100 tokens per step) |
| 20 | ├── agents/ # Optional: reusable executor agents |
| 21 | │ └── step-executor.md # Custom agent with specific tools/behavior |
| 22 | └── tasks/ # All task instructions directly here |
| 23 | ├── step-1-<name>.md # Full instructions (~500+ tokens each) |
| 24 | ├── step-2-<name>.md |
| 25 | ├── step-3-<name>.md |
| 26 | └── common-context.md # Shared context across workflows |
| 27 | ``` |
| 28 | |
| 29 | ## Key Principles |
| 30 | |
| 31 | ### 1. Context Isolation |
| 32 | |
| 33 | Each sub-agent gets its own isolated context window. The main orchestrator stays lean while sub-agents load detailed instructions from files. |
| 34 | |
| 35 | | Component | Context Cost | Purpose | |
| 36 | |-----------|--------------|---------| |
| 37 | | Orchestrator command | ~50-100 tokens/step | Dispatch and coordinate | |
| 38 | | Task file | ~500+ tokens | Detailed step instructions | |
| 39 | | Sub-agent base | ~294 tokens | System prompt overhead | |
| 40 | |
| 41 | ### 2. Sub-Agent Capabilities |
| 42 | |
| 43 | Sub-agents spawned via Task tool: |
| 44 | |
| 45 | | Capability | Available | Notes | |
| 46 | |------------|-----------|-------| |
| 47 | | Read tool | ✅ Yes | Can read any file | |
| 48 | | Write tool | ✅ Yes | If not restricted | |
| 49 | | Grep/Glob | ✅ Yes | For code search | |
| 50 | | Skills loading | ❌ No | Skills don't auto-load in sub-agents | |
| 51 | | Spawn sub-agents | ❌ No | Cannot nest Task tool | |
| 52 | | Resume context | ✅ Yes | Via `resume` parameter | |
| 53 | |
| 54 | ### 3. File Reference Pattern |
| 55 | |
| 56 | Use `${CLAUDE_PLUGIN_ROOT}` for portable paths within plugin: |
| 57 | |
| 58 | ```markdown |
| 59 | Read ${CLAUDE_PLUGIN_ROOT}/tasks/step-1-workflow-name.md and execute. |
| 60 | ``` |
| 61 | |
| 62 | Sub-agent will use Read tool to fetch the file content. |
| 63 | |
| 64 | ## Implementation Process |
| 65 | |
| 66 | ### Step 1: Gather Requirements |
| 67 | |
| 68 | Ask user (if not provided): |
| 69 | |
| 70 | 1. **Workflow name**: kebab-case identifier (e.g., `feature-implementation`) |
| 71 | 2. **Description**: What the workflow accomplishes |
| 72 | 3. **Steps**: List of discrete steps with: |
| 73 | - Step name |
| 74 | - Step goal |
| 75 | - Required tools |
| 76 | - Expected output |
| 77 | 4. **Execution mode**: Sequential or parallel steps |
| 78 | 5. **Agent type**: `general-purpose` or custom agent |
| 79 | |
| 80 | ### Step 2: Create Directory Structure |
| 81 | |
| 82 | ```bash |
| 83 | # Create tasks directory (if it doesn't exist) |
| 84 | mkdir -p ${CLAUDE_PLUGIN_ROOT}/tasks |
| 85 | |
| 86 | # Optional: Create agents directory (if using custom agents) |
| 87 | mkdir -p ${CLAUDE_PLUGIN_ROOT}/agents |
| 88 | ``` |
| 89 | |
| 90 | **Note**: All task files (both workflow-specific steps and shared context) are placed directly in `tasks/` without subdirectories. |
| 91 | |
| 92 | ### Step 3: Create Task Files |
| 93 | |
| 94 | For each step, create a task file with this structure: |
| 95 | |
| 96 | ```markdown |
| 97 | # Step N: <Step Name> |
| 98 | |
| 99 | ## Context |
| 100 | You are executing step N of the <workflow-name> workflow. |
| 101 | |
| 102 | ## Goal |
| 103 | <Clear, specific goal for this step> |
| 104 | |
| 105 | ## Input |
| 106 | <What this step receives from previous steps or user> |
| 107 | |
| 108 | ## Instructions |
| 109 | 1. <Specific action> |
| 110 | 2. <Specific action> |
| 111 | 3. <Specific action> |
| 112 | |
| 113 | ## Constraints |
| 114 | - <Limitation or boundary> |
| 115 | - <What NOT to do> |
| 116 | |
| 117 | ## Expected Output |
| 118 | <What to return to orchestrator> |
| 119 | |
| 120 | ## Success Criteria |
| 121 | - [ ] <Measurable outcome> |
| 122 | - [ ] <Measurable outcome> |
| 123 | ``` |
| 124 | |
| 125 | ### Step 4: Create Orchestrator Command |
| 126 | |
| 127 | Create the main command file with this pattern: |
| 128 | |
| 129 | ```markdown |
| 130 | --- |
| 131 | description: <Workflow description> |
| 132 | argument-hint: <Required arguments> |
| 133 | allowed-tools: Task, Read |
| 134 | model: sonnet |
| 135 | --- |
| 136 | |
| 137 | # <Workflow Name> |
| 138 | |
| 139 | ## User Input |
| 140 | |
| 141 | \`\`\`text |
| 142 | $ARGUMENTS |
| 143 | \`\`\` |
| 144 | |
| 145 | ## Workflow Execution |
| 146 | |
| 147 | ### Step 1: <Step Name> |
| 148 | |
| 149 | Launch general-purpose agent: |
| 150 | - **Description**: "<3-5 word summary>" |
| 151 | - **Prompt**: |
| 152 | \`\`\` |
| 153 | Read ${CLAUDE_PLUGIN_ROOT}/tasks/step-1-<workflow>-<name>.md and execute. |
| 154 | |
| 155 | Context: |
| 156 | - TARGET: $1 |
| 157 | - MODE: $2 |
| 158 | \`\`\` |
| 159 | |
| 160 | **Capture**: <What to extract from result> |
| 161 | |
| 162 | ### Step 2: <Step Name> |
| 163 | |
| 164 | Launch general-purpose agent: |
| 165 | - **Description**: "<3-5 word summary>" |
| 166 | - **Prompt**: |
| 167 | \`\`\` |
| 168 | Read ${CLAUDE_PLUGIN_ROOT}/tasks/step-2-<workflow>-<name>.md and execute. |
| 169 | |
| 170 | Context from Step 1: |
| 171 | - <Key data from previous step> |
| 172 | \`\`\` |
| 173 | |
| 174 | ### Step 3: <Step Name> |
| 175 | |
| 176 | [Continue pattern...] |
| 177 | |
| 178 | ## Completion |
| 179 | |
| 180 | Summarize workflow results: |
| 181 | 1. <What was accomplished> |
| 182 | 2. <Key outputs> |
| 183 | 3. <Next steps if any> |
| 184 | ``` |
| 185 | |
| 186 | #### Frontmatter Options |
| 187 | |
| 188 | | Field | Purpose | Default | |
| 189 | |-------|---------|---------| |
| 190 | | `description` | Brief description of workflow purpose | Required | |
| 191 | | `argument-hint` | Expected arguments descrip |