Skip to content

Commit bcadcac

Browse files
rysweetgithub-actions[bot]claudeUbuntu
authored
feat(workflow): Enforce workflow classification via CLAUDE.md (#1686)
* feat(workflow): Enforce workflow classification via CLAUDE.md (#1680) Problem: Claude consistently ignored workflow instructions even when explicitly invoked with /ultrathink. Root cause was 4 levels of indirection (command -> skill -> skill -> workflow) causing context loss. Solution: - Add "MANDATORY: Workflow Selection" section to CLAUDE.md - Create Q&A_WORKFLOW.md (3 steps) for simple questions - Classify ALL tasks: Q&A, Investigation, or Default workflow - Deprecate /ultrathink command, ultrathink-orchestrator, default-workflow skills - Remove all /ultrathink references from CLAUDE.md Benefits: - Direct workflow enforcement without skill indirection - "Always use a workflow" is now enforceable (Q&A for simple questions) - Workflow classification happens in 3 seconds before any action - Backward compatibility: deprecated commands still work 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: Add workflow enforcement discovery to DISCOVERIES.md Documents the root cause (4 levels of indirection) and solution for issue #1680 where Claude ignored workflow instructions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat(workflow): Add runtime enforcement for DEFAULT_WORKFLOW steps Implements Issue #1680 - Prevents agents from skipping workflow steps by enforcing step completion at runtime via hooks. ## Problem Agents repeatedly skipped workflow steps (Steps 10, 16, 17, 21) despite Step 0 requiring explicit acknowledgement of all 22 steps. The existing workflow_tracker.py only logged but never enforced completion. ## Solution Three-module architecture with fail-open design: 1. **workflow_state.py**: State machine tracking step completion - Persists to .claude/runtime/workflow/state_{session_id}.json - Atomic file writes (temp + rename) - Tracks mandatory steps: {0, 10, 16, 17, 21} 2. **todo_interceptor.py**: Monitors TodoWrite for step tracking - Detects "Step N:" patterns in todo content - Validates Step 0 compliance (22 todos required) - Never blocks - only updates state and warns 3. **workflow_gate.py**: Gates stop hook completion - Requires Step 21 completion before task ends - Returns continuation prompt for incomplete workflows - Fail-open on errors (allows stop rather than blocking) ## Tests - 56 unit tests covering all three modules - TDD approach with testing pyramid (60/30/10) - E2E integration tests verify complete flow Closes #1680 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * fix(workflow): Address review feedback for enforcement module - Simplified regex patterns: consolidated 4 patterns into 1 tolerant pattern - Added MAX_STEP_NUMBER constant to prevent garbage matches - Fixed deprecated datetime.utcnow() → datetime.now(timezone.utc) - Added MAX_DISPLAYED_STEPS constant for continuation prompts All 56 workflow enforcement tests passing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs(workflow): Add runtime enforcement section to docs Explains the three-module enforcement system, mandatory steps, fail-open design, and state file persistence. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ubuntu <azureuser@azlin-vm-1764012546.ftnmxvem3frujn3lepas045p5c.xx.internal.cloudapp.net>
1 parent 84aca90 commit bcadcac

File tree

14 files changed

+2830
-84
lines changed

14 files changed

+2830
-84
lines changed

.claude/commands/amplihack/ultrathink.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
name: ultrathink
33
version: 1.0.0
44
description: Deep analysis mode with multi-agent orchestration
5+
DEPRECATED: true
6+
deprecation_notice: |
7+
This command is DEPRECATED as of 2025-11-26.
8+
Workflow selection is now handled directly in CLAUDE.md via the
9+
"MANDATORY: Workflow Selection" section. Use workflow classification
10+
directly instead of invoking /ultrathink.
11+
For backward compatibility, this command still works but routes to
12+
workflow classification in CLAUDE.md.
513
triggers:
614
- "Complex multi-step task"
715
- "Need deep analysis"
@@ -27,7 +35,7 @@ invokes:
2735
## Purpose
2836

2937
Deep analysis mode for complex tasks. Invokes workflow skills (default-workflow or investigation-workflow) based on task type, with automatic fallback to markdown workflows if skills are not yet available.
30-
You MUST use one of the workflow skills - either default-workflow or investigation-workflow or both or its possible the user could pass in additional workflow skills like cascade or debate.
38+
You MUST use one of the workflow skills - either default-workflow or investigation-workflow or both or its possible the user could pass in additional workflow skills like cascade or debate.
3139

3240
## EXECUTION INSTRUCTIONS FOR CLAUDE
3341

@@ -48,26 +56,27 @@ Execute this exact sequence for the task: `{TASK_DESCRIPTION}`
4856
- Development: @.claude/workflow/DEFAULT_WORKFLOW.md
4957
3. ALWAYS **Create a comprehensive todo list** using TodoWrite tool that includes all workflow steps/phases
5058
4. ALWAYS **Execute each step systematically**, marking todos as in_progress and completed
51-
52-
THERE IS NO VALUE in SKIPPING STEPS - DO NOT TAKE SHORTCUTS.
59+
60+
THERE IS NO VALUE in SKIPPING STEPS - DO NOT TAKE SHORTCUTS.
5361

5462
- **For Each Workflow Step**:
55-
- Mark step as in_progress in TodoWrite
56-
- Break down the step into smaller tasks if needed
57-
- Read the step requirements from workflow
58-
- Invoke specified agents via Task tool
59-
- Log decisions made
60-
- Mark step as completed
61-
- No steps are optional - all steps must be followed in sequence.
63+
- Mark step as in_progress in TodoWrite
64+
- Break down the step into smaller tasks if needed
65+
- Read the step requirements from workflow
66+
- Invoke specified agents via Task tool
67+
- Log decisions made
68+
- Mark step as completed
69+
- No steps are optional - all steps must be followed in sequence.
6270
- **Agent Invocation Pattern**:
6371

64-
```
65-
For step requiring "**Use** architect agent":
66-
→ Invoke Task(subagent_type="architect", prompt="[step requirements + task context]")
72+
```
73+
For step requiring "**Use** architect agent":
74+
→ Invoke Task(subagent_type="architect", prompt="[step requirements + task context]")
75+
76+
For step requiring multiple agents:
77+
→ Invoke multiple Task calls in parallel
78+
```
6779

68-
For step requiring multiple agents:
69-
→ Invoke multiple Task calls in parallel
70-
```
7180
### Agent Orchestration
7281

7382
#### When to Use Sequential
@@ -84,16 +93,16 @@ THERE IS NO VALUE in SKIPPING STEPS - DO NOT TAKE SHORTCUTS.
8493

8594
- **Decision Logging**:
8695

87-
After each major decision, append to DECISIONS.md:
88-
- What was decided
89-
- Why this approach
90-
- Alternatives considered
96+
After each major decision, append to DECISIONS.md:
97+
- What was decided
98+
- Why this approach
99+
- Alternatives considered
91100

92101
- **Mandatory Cleanup**:
93-
Always end with Task(subagent_type="cleanup")
94-
102+
Always end with Task(subagent_type="cleanup")
103+
95104
5. **Use the specified agents** for each step (marked with "**Use**" or "**Always use**")
96-
6. **MANDATORY: Enforce all steps.
105+
6. \*\*MANDATORY: Enforce all steps.
97106
7. **Track decisions** by creating and writing important decisions to `.claude/runtime/logs/<session_timestamp>/DECISIONS.md`
98107
8. **End with cleanup agent** (development) or knowledge capture (investigation)
99108

@@ -178,7 +187,7 @@ In these cases, pause development workflow at Step 4, run full INVESTIGATION_WOR
178187

179188
# ALWAYS PICK A WORKFLOW OR FOLLOW THE ONE THE USER TOLD YOU TO USE
180189

181-
YOU MAY NOT SKIP STEPS in the workflow.
190+
YOU MAY NOT SKIP STEPS in the workflow.
182191
UltraThink enhances the workflow with deep multi-agent analysis while respecting user customizations.
183192

184193
Remember: Ultra-thinking means thorough analysis before action, followed by ruthless cleanup.

.claude/skills/default-workflow/SKILL.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
name: default-workflow
33
version: 1.0.0
44
description: Development workflow for features, bugs, refactoring. Auto-activates for multi-file implementations.
5-
auto_activates:
6-
- "implement feature spanning multiple files"
7-
- "complex integration across components"
8-
- "refactor affecting 5+ files"
5+
DEPRECATED: true
6+
deprecation_notice: |
7+
This skill is DEPRECATED as of 2025-11-26.
8+
Workflow selection is now handled directly in CLAUDE.md via the
9+
"MANDATORY: Workflow Selection" section. Read the workflow file
10+
directly instead of using this skill wrapper.
11+
auto_activates: []
912
explicit_triggers:
1013
- /ultrathink
1114
- /amplihack:default-workflow

.claude/skills/ultrathink-orchestrator/SKILL.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
name: ultrathink-orchestrator
33
version: 1.0.0
44
description: Auto-invokes ultrathink workflow for any work request (default orchestrator)
5-
auto_activate: true
5+
DEPRECATED: true
6+
deprecation_notice: |
7+
This skill is DEPRECATED as of 2025-11-26.
8+
Workflow selection is now handled directly in CLAUDE.md via the
9+
"MANDATORY: Workflow Selection" section. The indirection through
10+
skills has been eliminated to ensure consistent workflow enforcement.
11+
auto_activate: false
612
priority: 5
713
triggers:
814
- "implement"

0 commit comments

Comments
 (0)