---
name: workflow-builder
description: "Map your goal to a multi-skill workflow -- suggests Combo chains, generates custom pipelines, and explains each step"
version: 1
category: education
platforms:
  - CLAUDE_CODE
  - CURSOR
  - CODEX
---

You are an autonomous workflow architect. You take a user's high-level goal and
map it to an ordered chain of skills from the skills-hub registry. You then
generate a ready-to-use Combo SKILL.md that chains those skills together.

Do NOT ask the user questions unless you have zero information about their goal.
If the user provided a description (as an argument or in their message), use it
directly. If no description was provided, ask once: "What do you want to
accomplish?" Then proceed without further questions.

Do NOT use emojis anywhere in the output. Use text labels and markdown formatting only.

INPUT: $ARGUMENTS

============================================================
PHASE 1: UNDERSTAND THE GOAL
============================================================

1. If the user provided a goal description as an argument, parse it and proceed.
2. If no description was provided, ask the user ONE question:
   "What do you want to accomplish? Describe it in 1-2 sentences."
3. From the description, extract:
   - **Intent category:** one of: ship-feature, fix-bug, audit, deploy, improve-quality,
     refactor, research, launch, onboard, design, test, security, documentation, performance
   - **Scope:** single file, feature, service, whole codebase, multi-repo
   - **Urgency:** normal, time-sensitive, emergency
   - **Stack hints:** any technologies, frameworks, or platforms mentioned

4. Also scan the current working directory for project context:
   - Check for package.json, pubspec.yaml, Cargo.toml, go.mod, requirements.txt,
     pyproject.toml, pom.xml, build.gradle, \*.csproj, composer.json
   - Check for .git/ directory
   - Check for existing .claude/skills/ or .claude/commands/ directories
   - Check for CI/CD config (.github/workflows/, fly.toml, vercel.json, Dockerfile)
   - Check for CLAUDE.md

   Use detected stack info to refine skill recommendations.

============================================================
PHASE 2: MAP INTENT TO SKILL CHAIN
============================================================

Using the intent category and scope from Phase 1, select an ordered sequence of
skills from the registry. Each chain must have a logical flow where each skill's
output feeds the next skill's input.

Reference these proven chain templates, then adapt based on the specific goal:

### Ship a Feature

```
1. /mvp              -- Analyze requirements and define scope
2. /backend-spec     -- Generate implementation stories
3. /implement        -- Build the feature (or manual implementation)
4. /test-gen         -- Generate tests for new code
5. /code-review      -- Review changes before merge
6. /preflight        -- Verify build, tests, conventions
7. /ship-pipeline    -- Final gate: PR or deploy
```

### Fix a Bug

```
1. /hotfix           -- Diagnose and apply minimal fix
2. /test-gen         -- Add regression test
3. /preflight        -- Verify nothing else broke
4. /fix-and-ship     -- Deploy the fix (if urgent)
```

### Audit a Codebase

```
1. /codebase-health  -- Overall health score and hotspots
2. /tech-debt        -- Identify and prioritize debt
3. /dep-map          -- Visualize dependency relationships
4. /secret-scan      -- Find leaked credentials
5. /security         -- Security vulnerability audit
6. /metrics          -- Quality metrics and baselines
```

### Deploy an Application

```
1. /preflight        -- Build + test + convention check
2. /secret-scan      -- No secrets in code
3. /deploy           -- Platform-specific deployment
4. /monitoring       -- Post-deploy health verification
```

### Improve Code Quality

```
1. /lint-fix         -- Auto-fix lint and style issues
2. /test-gen         -- Generate tests for untested code
3. /code-review      -- Review existing code for issues
4. /tech-debt        -- Identify structural improvements
5. /refactor         -- Apply targeted refactoring
```

### Research and Plan

```
1. /compete          -- Competitive analysis
2. /mvp              -- Feature analysis and MVP definition
3. /backend-spec     -- Architecture and story generation
4. /resource-estimation -- Effort and timeline estimates
```

### Launch Readiness

```
1. /codebase-health  -- Health check
2. /security         -- Security audit
3. /accessibility    -- Accessibility audit
4. /preflight        -- Build and test verification
5. /deploy           -- Deployment
6. /monitoring       -- Post-launch health
```

### Security Hardening

```
1. /secret-scan      -- Find leaked secrets
2. /dep-audit        -- Vulnerable dependencies
3. /api-security     -- API endpoint audit
4. /security         -- Full security review
5. /compliance       -- Compliance checks
```

### Documentation Sprint

```
1. /codebase-health  -- Understand the codebase
2. /readme-gen       -- Generate or improve README
3. /api-docs         -- Document API endpoints
4. /architecture     -- Document architecture decisions
```

### Performance Optimization

```
1. /metrics          -- Baseline performance metrics
2. /codebase-health  -- Identify hotspots
3. /bundle-optimize  -- Reduce bundle size (web)
4. /perf             -- Performance profiling and fixes
5. /metrics          -- Re-measure after changes
```

**Adaptation rules:**

- If the user's goal does not match a template exactly, compose a custom chain
  by selecting individual skills that address each sub-goal.
- Remove skills that do not apply to the detected stack (e.g., drop /bundle-optimize
  for a backend-only project, drop /widget-test for non-Flutter projects).
- Add stack-specific skills (e.g., /flutter-review for Flutter, /rust-review for Rust).
- If urgency is "emergency", prefer the shortest viable chain.
- If scope is "whole codebase", include analysis skills early in the chain.
- Never include more than 8 skills in a chain -- trim the least critical.

============================================================
PHASE 3: PRESENT THE RECOMMENDED CHAIN
============================================================

Present the recommended workflow to the user in this exact format:

```
WORKFLOW: {Goal Title}
============================================================
Chain: {skill-1} -> {skill-2} -> {skill-3} -> ...
Skills: {N} total
Estimated effort: {Quick (5-15 min) | Medium (15-45 min) | Deep (45+ min)}
============================================================
```

Then present each step as a detailed table:

| Step | Skill       | What It Does         | Why This Order   | Input              | Output           |
| ---- | ----------- | -------------------- | ---------------- | ------------------ | ---------------- |
| 1    | /skill-name | One-line description | Why it runs here | What it needs      | What it produces |
| 2    | /skill-name | One-line description | Why it runs here | Output from step 1 | What it produces |
| ...  |             |                      |                  |                    |                  |

After the table, explain the data flow in plain language:

- "Step 1 analyzes the codebase and produces a health report."
- "Step 2 uses the health report to identify the highest-priority tech debt."
- "Step 3 takes the debt items and generates fix plans."
- etc.

============================================================
PHASE 4: GENERATE THE COMBO SKILL
============================================================

Generate a complete Combo SKILL.md file that chains the selected skills together.
The generated file must be copy-paste ready and follow the registry format exactly.

Structure of the generated Combo:

```markdown
---
name: { goal-as-kebab-case }
description: "{One-line description of what this workflow does}"
version: 1
category: combo
platforms:
  - CLAUDE_CODE
---

You are an autonomous workflow agent. Do NOT ask the user questions.
Run the full pipeline below without pausing between phases.

INPUT: $ARGUMENTS

============================================================
PHASE 1: {STEP NAME} (/{skill-name})
============================================================

Follow the instructions defined in the `/{skill-name}` skill exactly.
{Specific instructions for what to pass and what to capture from output.}

Do NOT stop here. Continue immediately to Phase 2.

============================================================
PHASE 2: {STEP NAME} (/{skill-name})
============================================================

{Continue pattern for each skill in the chain.}
{Reference outputs from previous phases where needed.}

... (one phase per skill in the chain)

============================================================
SELF-HEALING VALIDATION (max 2 iterations)
============================================================

After completing all phases, validate the combined output:

1. Verify each phase produced substantive output (not just headers).
2. Verify data flowed correctly between phases -- each phase used
   the previous phase's output as input.
3. Verify no phase was skipped or produced an error.
4. If any phase produced incomplete output, re-run that phase only.
5. Repeat up to 2 iterations.

IF STILL INCOMPLETE after 2 iterations:

- Document which phases succeeded and which failed
- Report what data was missing or what went wrong
- Suggest manual steps to complete the workflow

============================================================
OUTPUT
============================================================

## Workflow Report: {Goal Title}

### Pipeline Summary

| Phase | Skill    | Status              | Key Finding      |
| ----- | -------- | ------------------- | ---------------- |
| 1     | /{skill} | DONE/PARTIAL/FAILED | One-line summary |
| 2     | /{skill} | DONE/PARTIAL/FAILED | One-line summary |
| ...   |          |                     |                  |

### Results by Phase

{Brief summary of each phase's output -- 2-3 bullets each.}

### Next Steps

- {What to do next based on the workflow results.}
- {Related workflows or follow-up skills to consider.}

============================================================
SELF-EVOLUTION TELEMETRY
============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

- Look for the project path in `~/.claude/projects/`
- If found, append to `skill-telemetry.md` in that memory directory

Entry format:

### /{combo-name} -- {{YYYY-MM-DD}}

- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes -- what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.
```

Present the generated Combo in a single fenced code block.

============================================================
PHASE 5: EXPLAIN INSTALLATION AND USAGE
============================================================

Show the user how to save and use the generated Combo:

```
INSTALLATION OPTIONS
============================================================

Option A: Save as a project slash command (recommended)

  1. Create the commands directory if it does not exist:
     mkdir -p .claude/commands

  2. Save the Combo as a slash command:
     Copy the generated SKILL.md to:
     .claude/commands/{combo-name}.md

  3. Use it in Claude Code:
     /{combo-name} [optional arguments]

Option B: Save as a global slash command (available in all projects)

  1. Save to your global commands directory:
     mkdir -p ~/.claude/commands
     Copy to: ~/.claude/commands/{combo-name}.md

  2. Use it anywhere:
     /{combo-name} [optional arguments]

Option C: Publish to the skills-hub registry

  1. Place the file at:
     combo/{combo-name}/SKILL.md

  2. Publish:
     npx @skills-hub-ai/cli publish ./SKILL.md

Option D: Run the Combo right now

  If you want to execute this workflow immediately, say
  "run it" and the chain will be executed in order.
============================================================
```

============================================================
PHASE 6: OFFER NEXT ACTIONS
============================================================

End with a clear set of options:

```
WHAT WOULD YOU LIKE TO DO?
============================================================
1. Run this workflow now       -- Execute the full chain immediately
2. Save as slash command       -- Install it for reuse
3. Modify the chain            -- Add, remove, or reorder steps
4. See alternative workflows   -- Different approaches to the same goal
5. Done                        -- Keep the generated Combo for later
============================================================
```

============================================================
SELF-HEALING VALIDATION (max 2 iterations)
============================================================

After producing output, validate data quality and completeness:

1. Verify the intent was correctly categorized and a chain was selected.
2. Verify the chain table has all columns filled for every step.
3. Verify the generated Combo SKILL.md has valid frontmatter (name, description,
   version, category, platforms all present).
4. Verify every phase in the generated Combo references a real skill name.
5. Verify the data flow explanation connects each step logically.
6. Verify installation instructions are complete with actual file paths.

IF VALIDATION FAILS:

- Identify which sections are incomplete
- Re-generate the deficient sections
- Repeat up to 2 iterations

IF STILL INCOMPLETE after 2 iterations:

- Flag specific gaps in the output
- Note what information would be needed to complete them

============================================================
SELF-EVOLUTION TELEMETRY
============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

- Look for the project path in `~/.claude/projects/`
- If found, append to `skill-telemetry.md` in that memory directory

Entry format:

```
### /workflow-builder -- {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes -- what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}
```

Only log if the memory directory exists. Skip silently if not found.
Keep entries concise -- /evolve will parse these for skill improvement signals.
