# workflow-create > Creates a multi-hook workflow chain with state management. Use when: building automated sequences, validation pipelines, or complex hook orchestrations. - Author: Edison - Repository: soilmass/claudeutils - Version: 20260127023329 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/soilmass/claudeutils - Web: https://mule.run/skillshub/@@soilmass/claudeutils~workflow-create:20260127023329 --- --- name: workflow-create description: >- Creates a multi-hook workflow chain with state management. Use when: building automated sequences, validation pipelines, or complex hook orchestrations. license: MIT metadata: author: claudeutils version: "1.0.0" allowed-tools: Read Write Glob Bash disable-model-invocation: true user-invocable: true argument-hint: " [--events event1,event2,...] [description]" --- ## Task Create a new workflow with coordinated hooks and state management. ## Input - `$0`: Workflow name (lowercase, hyphens, 1-64 chars) - `--events`: Comma-separated list of events (default: PreToolUse,PostToolUse) - `$ARGUMENTS`: Optional workflow description ## Common Workflow Patterns | Pattern | Events | Use Case | |---------|--------|----------| | Create workflow | PreToolUse(Write), PostToolUse(Write), PostToolUseFailure | File creation with validation | | Review workflow | SessionStart, SubagentStart, SubagentStop | Code review with metrics | | Build workflow | PreToolUse(Bash), PostToolUse(Bash) | Build/test automation | | Guard workflow | PreToolUse, PermissionRequest | Security validation | ## Instructions 1. **Validate input** - Name: 1-64 chars, lowercase, hyphens - Events: must be valid hook events 2. **Analyze workflow pattern** - Map events to hook types - Determine required hooks 3. **Create workflow directory** ``` hooks/workflows/{name}/ ├── pre-{tool}-validate.sh (if PreToolUse) ├── post-{tool}-verify.sh (if PostToolUse) ├── handle-failure.sh (if PostToolUseFailure) ├── on-start.sh (if SubagentStart) └── on-stop.sh (if SubagentStop) ``` 4. **Generate hook scripts** from templates with: - Library imports - Workflow-specific state checking - Coordinated state updates - Proper exit codes 5. **Generate settings.json snippet** 6. **Update detect-workflow.sh** pattern ## Output ### Success ``` Created workflow: {name} Directory: hooks/workflows/{name}/ Files created: - pre-tool-validate.sh - post-tool-verify.sh - handle-failure.sh State file pattern: state/{name}-{session}.json Add to .claude/settings.json: {settings_snippet} Workflow state schema: { "workflow": "{name}", "status": "active|completed|failed", "steps": { "validate": {"status": "pending|completed|failed"}, "verify": {"status": "pending|completed|failed"} }, "context": {} } Next steps: 1. Edit hook scripts to add validation logic 2. Register hooks in settings.json 3. Test: WORKFLOW={name} to manually activate ``` ### Error ``` ERROR: INPUT what: Invalid workflow name where: $0 = "{provided_name}" why: {specific_reason} fix: Use lowercase letters, numbers, and hyphens (1-64 chars) ``` ## Template Reference existing workflow: hooks/workflows/skill-create/