AgentSkillsCN

creating-workflows

指导创建冲刺工作流定义。当用户想要创建新工作流、修改现有工作流、理解工作流架构,或定义阶段序列时,应使用此技能。可通过“创建工作流”、“新工作流”、“工作流定义”、“定义阶段”等短语进行触发。

SKILL.md
--- frontmatter
name: creating-workflows
description: Guide for creating sprint workflow definitions. This skill should be used when users want to create a new workflow, modify existing workflows, understand workflow schema, or define phase sequences. Triggers on "create workflow", "new workflow", "workflow definition", "define phases".

Creating Workflows

Guide for authoring sprint workflow definitions in .claude/workflows/.

Before You Start

For complete reference, read these files:

  1. Schema: references/workflow-schema.md - Full field definitions
  2. Examples: .claude/workflows/ - Working workflow files

The Quick Reference below covers common cases. For edge cases, consult the schema.

Quick Reference (Cheat Sheet)

Workflow Structure

yaml
name: <string>           # Required
description: <string>    # Optional
phases:                  # Required - list of phases
  - id: <string>         # Required, unique identifier
    prompt: <string>     # For simple phases (direct execution)
    # OR
    for-each: <string>   # Collection name to iterate
    workflow: <string>   # Workflow to run per item

Phase Types

TypeRequired FieldsUse Case
Simpleid, promptDirect execution of instructions
For-Eachid, for-each, workflowIterate over collection items

Template Variables

VariableDescription
{{item.prompt}}Current item's prompt
{{item.id}}Current item's ID
{{sprint.id}}Sprint identifier
{{sprint.name}}Sprint name

Optional Phase Fields

FieldTypeDescription
parallelbooleanRun in background (item workflows only)
wait-for-parallelbooleanSync point for parallel tasks
breakbooleanPause for human review after completion
gateobjectQuality gate script + on-fail handling

Current Workflow Patterns

sprint-default.yaml

Phases: prepare → development (for-each) → qa → deploy Use for: Standard sprint execution with QA gates

plugin-development.yaml

Phases: preflight → development (TDD) → docs → tooling → version → qa → summary → pr Use for: Plugin development with TDD and documentation

feature-standard.yaml

Phases: planning → implement → test → document Use for: Single feature implementation

bugfix-workflow.yaml

Phases: diagnose → fix → verify Use for: Bug investigation and fixing

What is a Workflow?

ConceptDescription
WorkflowYAML file defining execution phases
PhaseIndividual step with prompt or iteration
For-EachPhase that iterates over collection items
Template VariablesDynamic values substituted at runtime
Quality GateValidation script with retry-on-fail capability
BreakpointPause point for human review before continuing

Workflow Location

text
.claude/workflows/
├── sprint-default.yaml     # Top-level sprint workflow
├── feature-standard.yaml   # Step-level implementation workflow
├── bugfix-workflow.yaml    # Quick bug fix workflow
└── custom-workflow.yaml    # Your custom workflows

Quick Start

1. Create Workflow File

yaml
# .claude/workflows/my-workflow.yaml
name: My Custom Workflow
description: Brief description of workflow purpose

phases:
  - id: first-phase
    prompt: |
      Instructions for first phase.
      {{item.prompt}}

  - id: second-phase
    prompt: |
      Instructions for second phase.

2. Reference in SPRINT.yaml

yaml
workflow: my-workflow
collections:
  step:
    - prompt: Implement feature X
    - prompt: Add tests for feature X

Phase Types Decision Tree

text
Do you need to process multiple collection items?
├── YES → Use for-each phase
│         └── for-each: step    # or: feature, bug, etc.
│             workflow: step-workflow
│
└── NO → Use simple phase
         └── prompt: "Instructions here"

Workflow Patterns

PatternUse CaseExample
Simple SequentialLinear task flowprepare → execute → verify
For-Each DevelopmentItem iterationdevelopment phase with for-each: step
Nested WorkflowComplex step executionFor-each phase referencing step workflow
HybridMixed phasesSimple + for-each combined

Template Variables

VariableAvailable InValue
{{item.prompt}}For-each phasesItem description from collection
{{item.id}}For-each phasesItem identifier (e.g., step-0)
{{item.index}}For-each phases0-based item index
{{item.<prop>}}For-each phasesAny custom property from the item
{{<type>.prompt}}For-each phasesType-specific alias (e.g., {{step.prompt}} when for-each: step)
{{phase.id}}All phasesCurrent phase identifier
{{sprint.id}}All phasesSprint identifier
{{sprint.name}}All phasesSprint name (if set)

Example Workflows

Minimal Workflow

yaml
name: Minimal Execute
phases:
  - id: execute
    prompt: "Execute the task: {{item.prompt}}"

Sprint Workflow with For-Each

yaml
name: Standard Sprint
phases:
  - id: prepare
    prompt: "Prepare sprint environment"

  - id: development
    for-each: step
    workflow: feature-standard

  - id: qa
    prompt: "Run tests and quality checks"

  - id: deploy
    prompt: "Create PR and finalize"

Quality Gates and Breakpoints

Quality Gate

Run validation scripts after phase completion with automatic retry:

yaml
phases:
  - id: implement
    prompt: "Implement the feature..."
    gate:
      script: "npm run build && npm test"
      on-fail:
        prompt: "Fix build/test failures: {{gate.output}}"
        max-retries: 3
      timeout: 120

Breakpoint

Pause for human review after phase completes:

yaml
phases:
  - id: prepare-release
    prompt: "Prepare release artifacts..."
    break: true  # Sprint pauses with status: paused-at-breakpoint

  - id: deploy
    prompt: "Deploy to production..."  # Runs after /resume-sprint

See references/workflow-schema.md for full gate and breakpoint documentation.

References

  • references/workflow-schema.md - Complete YAML schema
  • references/template-variables.md - All available variables
  • references/phase-types.md - Simple vs for-each phases
  • references/workflow-patterns.md - Common patterns

Assets

  • assets/feature-workflow.yaml - Feature implementation template
  • assets/bugfix-workflow.yaml - Bug fix template
  • assets/validation-checklist.md - Pre-deployment checklist

Validation

Before using a workflow:

  1. Check YAML syntax is valid
  2. Verify all phase IDs are unique
  3. Ensure for-each phases have workflow reference
  4. Confirm referenced workflows exist in .claude/workflows/
  5. Test template variables resolve correctly

Troubleshooting

IssueCauseResolution
Workflow not foundMissing fileCreate in .claude/workflows/
Phase skippedMissing prompt or for-eachAdd required field
Variable not resolvedWrong contextCheck variable availability (item.* only in for-each)
Compilation errorInvalid YAMLValidate YAML syntax

Related

  • orchestrating-sprints - Running and managing sprints
  • creating-sprints - Creating SPRINT.yaml definitions