.github/skills/workflows-work/SKILL.md
Execute work plans while maintaining WHY tracing from problem narrative through user story to implementation. Grounds every subagent in purpose.
npx skillsauth add the-rabak/compound-engineering-plugin workflows-workInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
[plan file, specification, or todo file path] [--review-mode bulk|inline|both]
Execute a work plan while maintaining WHY tracing from problem narrative through implementation.
This command takes a work document (plan, specification, or todo file) and executes it systematically using a subagent orchestration model. The orchestrator (this conversation) decomposes the plan into scoped chunks and delegates each to a focused subagent. Each subagent follows a standardized 4-phase protocol (understand, implement, self-review, report) defined in the execution agent prompt template.
WHY-grounded execution: Every subagent receives the plan's WHY context -- the problem narrative, user story, architectural context, and which success criterion their specific task serves. This prevents implementation drift where technically correct code fails to deliver the user's actual need. The orchestrator is the guardian of WHY: it extracts purpose from the plan, threads it through every task prompt, and validates that the combined output delivers the stated user story.
This command supports a --review-mode argument that controls when code review happens:
bulk (default) -- Review happens after ALL tasks complete, using /workflows-review. This is the standard behavior and is fastest for most work.inline -- After each task, a lightweight two-stage review (spec compliance then code quality) runs automatically. Catches spec drift early but adds 2-4 extra subagent calls per task.both -- Inline review per task AND comprehensive /workflows-review at the end. Maximum quality assurance.If no --review-mode is specified, check compound-engineering.local.md for a review_mode setting. If not found there either, default to bulk.
<input_document> #$ARGUMENTS </input_document>
Read Plan and Extract WHY Context
handoff: frontmatter in the plan. If present, verify all flags are true (problem_narrative, user_story, architectural_context, success_criteria). If any are false, warn the user that WHY context is incomplete and suggest running /workflows-brainstorm or /workflows-plan first.brainstorm_ref: path, read that brainstorm document too for richer WHY contextSetup Environment
First, check the current branch:
current_branch=$(git branch --show-current)
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
# Fallback if remote HEAD isn't set
if [ -z "$default_branch" ]; then
default_branch=$(git rev-parse --verify origin/main >/dev/null 2>&1 && echo "main" || echo "master")
fi
If already on a feature branch (not the default branch):
[current_branch], or create a new branch?"If on the default branch, choose how to proceed:
Option A: Create a new branch
git pull origin [default_branch]
git checkout -b feature-branch-name
Use a meaningful name based on the work (e.g., feat/user-authentication, fix/email-validation).
Option B: Use a worktree (recommended for parallel development)
skill: git-worktree
# The skill will create a new branch from the default branch in an isolated worktree
Option C: Continue on the default branch
Recommendation: Use worktree if:
Preview Task Breakdown
Phase 2 is where the orchestrator (this conversation) decomposes the plan into scoped chunks and delegates each to a focused subagent. The orchestrator does NOT implement code itself -- it decomposes, delegates, records, and routes.
Before executing, validate two things: structural readiness (tasks are granular and testable) and WHY readiness (the plan carries purpose context).
Structural readiness -- each implementation task should have:
WHY readiness -- the plan should have:
If the plan lacks structural details, refuse to proceed and suggest running /deepen-plan or manually breaking down the plan.
If the plan lacks WHY artifacts, the orchestrator should construct minimal WHY context before proceeding:
Before creating a new session, check for existing incomplete sessions for the same plan:
ls docs/execution-sessions/work-*/state.md 2>/dev/null
If a previous session exists for the same plan file and has status: in_progress:
[session_id] for this plan. Resume where you left off, or start fresh?"current_task-archived suffix), then start a new sessionIf no resumable session exists, proceed to Step 3.
Create a persistent execution session to track progress:
SESSION_ID="work-$(date +%Y-%m-%d-%H%M%S)"
mkdir -p docs/execution-sessions/${SESSION_ID}
Create a STATE.md file in the session directory:
---
plan_file: [path to plan]
brainstorm_ref: [path to brainstorm, if available]
started: [ISO timestamp]
status: in_progress
current_task: 0
total_tasks: [count]
session_id: [SESSION_ID]
---
## WHY Context
### Problem Narrative
[Extracted from plan -- why this work exists]
### User Story
[Extracted from plan -- who benefits and what outcome]
### Architectural Context
[Extracted from plan -- how this fits in the system]
### Success Criteria
[Extracted from plan -- measurable conditions for "done"]
## Task Status
| # | Task | Serves | Status | Attempts | Session File |
|---|------|--------|--------|----------|--------------|
| 1 | [task name] | [which user story aspect] | pending | -- | -- |
| 2 | [task name] | [which user story aspect] | pending | -- | -- |
...
## Learnings Brief
_No learnings yet._
The orchestrator parses the plan and creates a list of execution chunks. Each chunk is a self-contained unit of work. The orchestrator does the heavy lifting here:
If the plan already has well-defined tasks with success criteria, use them directly. If not, the orchestrator must create them before proceeding.
For each task (or parallel batch of tasks), follow this cycle:
For each task, the orchestrator constructs a focused prompt by reading the execution agent prompt template from commands/workflows/references/execution-agent-prompt.md and filling in the context blocks:
## Why This Task Exists
**Problem:** [problem narrative from plan -- 1-2 sentences]
**User Story:** [user story from plan]
**This task serves:** [the "Serves:" line from this task's parent phase -- which user story aspect or success criterion this delivers]
**Overall success criteria:** [plan-level success criteria list]
tdd_enabled: true in compound-engineering.local.md, include the TDD Implementation Section from the template; otherwise include the Standard Implementation SectionThe execution agent template instructs each subagent to follow a 4-phase protocol:
Delegate the task to a focused subagent:
Task(general-purpose, prompt=scoped_prompt)
The subagent prompt is constructed from the execution agent template (commands/workflows/references/execution-agent-prompt.md). The template already includes instructions for the 4-phase protocol (understand, implement, self-review, report). The orchestrator fills in the context blocks and passes the result:
For parallel tasks: Spawn multiple subagents simultaneously. Only parallelize tasks with non-overlapping file sets. Before parallelizing, verify file sets do not overlap.
Example scoped prompt:
You are implementing Task 3 of a feature plan. Here is your scoped context:
## Why This Task Exists
**Problem:** Users currently cannot authenticate, forcing manual session management that's error-prone and insecure.
**User Story:** As a user, I want to log in with my credentials so that I can access my personalized dashboard securely.
**This task serves:** "Secure authentication flow" -- implementing the core token generation that enables the login experience.
**Overall success criteria:**
- Users can log in and receive a JWT token
- Invalid credentials are rejected with clear error messages
- Tokens expire after the configured TTL
## Task
Create the UserAuthService with JWT token generation and validation.
## Files to Create/Modify
- Create: `src/services/UserAuthService.ts`
- Create: `tests/UserAuthService.test.ts`
- Modify: `src/app.ts` (register service)
## Success Criteria
- [ ] UserAuthService instantiates correctly
- [ ] authenticate() returns JWT token for valid credentials
- [ ] authenticate() throws AuthenticationError for invalid credentials
- [ ] Token validation works for valid and expired tokens
## Test Command
npm test -- --filter UserAuthService
## Architectural Context
JWT-based stateless auth. Tokens issued by UserAuthService, validated by middleware (Task 4). No server-side session storage.
## Conventions
- Use dependency injection pattern
- Variables are camelCase
- Type annotations on all parameters and return types
## Learnings from Previous Tasks
- [backend] Use jest.mock() for module mocking
- [backend] Factory pattern: createUser() helper not new User()
- [testing] Use expect().toThrow() for error assertions
## Instructions
1. Read the referenced files and understand existing patterns
2. Implement the task following the conventions above
3. Write tests matching the success criteria
4. Run the test command
5. If tests fail: analyze, fix, retry (up to 3 attempts)
6. Return a structured report: summary, files changed, problems encountered and fixes, patterns discovered, test results, attempt count
When the subagent returns, the orchestrator processes the results:
1. Write session file to docs/execution-sessions/${SESSION_ID}/task-{nn}-{slug}.md:
---
task: "[task name]"
task_number: [n]
serves: "[which user story aspect / success criterion this task delivers]"
status: [completed|failed]
attempt_count: [n]
domains: [backend, frontend, testing, database, etc.]
plan_file: [path]
session_id: [SESSION_ID]
---
## What Was Implemented
[From subagent report]
## Files Changed
- `path/to/file.php` -- created/modified
## Problems Encountered
### Problem 1: [title]
- **Error:** [exact error message]
- **Root cause:** [analysis]
- **Fix:** [what was done]
### Problem 2: ...
## Patterns Discovered
- [pattern 1]
- [pattern 2]
## Test Results
- Command: `[test command]`
- Result: PASS/FAIL
- Attempts: [n]
2. Inline Review (when --review-mode inline or --review-mode both)
If the --review-mode argument is inline or both, perform a two-stage inline review before proceeding to the next task. If --review-mode is bulk (the default), skip this step.
Stage 1: Spec Compliance Review
Read the spec review prompt template from commands/workflows/references/spec-review-prompt.md. Fill in:
{{TASK_REQUIREMENTS}} -- the task description and success criteria{{SUCCESS_CRITERIA}} -- the success criteria checkboxes{{IMPLEMENTER_REPORT}} -- the execution report from the subagent{{TASK_SERVES}} -- what user story aspect this task delivers (from the task's "Serves:" line)Spawn a spec reviewer subagent:
Task(general-purpose, prompt=filled_spec_review_prompt)
The spec reviewer should check not just checkbox compliance but whether the implementation actually delivers on the purpose stated in "Serves:". A task can pass all checkboxes but miss the intent.
Stage 2: Code Quality Review (only after spec compliance passes)
Read the quality review prompt template from commands/workflows/references/quality-review-prompt.md. Fill in:
{{IMPLEMENTER_REPORT}} -- the execution report{{FILES_CHANGED}} -- list of files from the reportSpawn a quality reviewer subagent:
Task(general-purpose, prompt=filled_quality_review_prompt)
/workflows-review if run later)Note: Inline review is a lightweight per-task check. It does NOT replace the comprehensive /workflows-review multi-agent review. When --review-mode both is active, inline review runs per-task AND /workflows-review runs after all tasks complete.
3. Update STATE.md -- mark the task status, increment current_task, update the task status table
4. Update learnings brief -- add new learnings from this task, tagged by domain, deduplicated against existing learnings
5. Update plan file -- check off completed items ([ ] to [x]) in the original plan document
6. Regression guard -- run test commands from ALL previously completed tasks. If any regress:
7. Incremental commit if appropriate (logical unit complete, tests pass):
| Commit when... | Don't commit when... | |----------------|---------------------| | Logical unit complete (model, service, component) | Small part of a larger unit | | Tests pass + meaningful progress | Tests failing | | About to switch contexts (backend to frontend) | Purely scaffolding with no behavior | | About to attempt risky/uncertain changes | Would need a "WIP" commit message |
Heuristic: "Can I write a commit message that describes a complete, valuable change? If yes, commit. If the message would be 'WIP' or 'partial X', wait."
# 1. Verify tests pass (use project's test command)
# 2. Stage only files related to this logical unit (not `git add .`)
git add <files related to this logical unit>
# 3. Commit with conventional message
git commit -m "feat(scope): description of this unit"
Note: Incremental commits use clean conventional messages without attribution footers. The final Phase 4 commit/PR includes the full attribution.
If a subagent fails after its internal retries:
skipped in STATE.md. Note it as a blocker for any dependent tasks. Dependent tasks are also skipped automatically.status: paused, present a summary of what was completed and what remains.Run Core Quality Checks
Always run before submitting:
# Run full test suite (use project's test command)
# Detect and run: npm test, pytest, cargo test, phpunit, go test, etc.
# Run linting (per CLAUDE.md)
# Use project-specific linter: eslint, ruff, clippy, pint, etc.
Purpose Validation (REQUIRED)
Before mechanical quality checks, validate that the combined work delivers on the WHY:
If purpose validation reveals gaps, present them to the user before proceeding to PR.
Consider Reviewer Agents (Optional)
Use for complex, risky, or large changes. Read agents from compound-engineering.local.md frontmatter (review_agents). If no settings file, invoke the setup skill to create one.
Run configured agents in parallel with Task tool. Pass the WHY context (problem narrative, user story, success criteria) to reviewer agents so they can evaluate fitness for purpose, not just code quality. Present findings and address critical issues.
Final Validation
completed (or explicitly skipped with user approval)Prepare Operational Validation Plan (REQUIRED)
## Post-Deploy Monitoring & Validation section to the PR description for every change.No additional operational monitoring required and a one-line reason.Use the finishing-branch skill for structured branch completion. This skill handles final verification, commit, merge/PR options, worktree cleanup, and plan status updates.
skill: finishing-branch
If the finishing-branch skill is not available, follow the manual steps below:
Create Commit
git add .
git status # Review what's being committed
git diff --staged # Check the changes
# Commit with conventional format
git commit -m "$(cat <<'EOF'
feat(scope): description of what and why
Brief explanation if needed.
EOF
)"
Capture and Upload Screenshots for UI Changes (REQUIRED for any UI work)
For any design changes, new views, or UI modifications, you MUST capture and upload screenshots:
Step 1: Start dev server (if not running)
# Laravel: Docker containers should be running
# Frontend: npm run dev
Step 2: Capture screenshots with agent-browser CLI
agent-browser open http://localhost:[port]/[route]
agent-browser snapshot -i
agent-browser screenshot output.png
See the agent-browser skill for detailed usage.
Step 3: Upload using imgup skill
skill: imgup
# Then upload each screenshot:
imgup -h pixhost screenshot.png # pixhost works without API key
# Alternative hosts: catbox, imagebin, beeimg
What to capture:
IMPORTANT: Always include uploaded image URLs in MR description. This provides visual context for reviewers and documents the change.
Push Branch and Create Merge Request
git push -u origin feature-branch-name
After pushing, inform the user with the MR description template below. They can create the MR in GitLab's web UI or using glab mr create if available.
MR Description Template:
## Summary
- **Problem:** [from plan's Problem Narrative]
- **User Story:** [from plan's User Story]
- **What was built:** [concrete description of implementation]
- **Key decisions made:** [architectural or design choices]
## Success Criteria Status
- [x] [criterion 1 from plan] -- delivered by Task N
- [x] [criterion 2 from plan] -- delivered by Task N
- [ ] [criterion 3 if skipped] -- skipped: [reason]
## Testing
- Tests added/modified
- Manual testing performed
## Post-Deploy Monitoring & Validation
- **What to monitor/search**
- Logs:
- Metrics/Dashboards:
- **Validation checks (queries/commands)**
- `command or query here`
- **Expected healthy behavior**
- Expected signal(s)
- **Failure signal(s) / rollback trigger**
- Trigger + immediate action
- **Validation window & owner**
- Window:
- Owner:
- **If no operational impact**
- `No additional operational monitoring required: <reason>`
## Before / After Screenshots
| Before | After |
|--------|-------|
|  |  |
## Figma Design
[Link if applicable]
---
[](https://github.com/The-Rabak/compound-engineering-plugin)
Save the MR description to a file the user can copy from:
# Write MR description to a temp file for easy copy-paste
cat > /tmp/mr-description.md <<'MRDESC'
[filled-in MR description from template above]
MRDESC
echo "MR description saved to /tmp/mr-description.md"
Finalize Execution Session
Update the session STATE.md:
status: completedIf the input document has YAML frontmatter with a status field, update it to completed:
status: active → status: completed
Notify User
For complex plans with multiple independent workstreams, enable swarm mode for parallel execution with coordinated agents.
| Use Swarm Mode when... | Use Standard Mode when... | |------------------------|---------------------------| | Plan has 5+ independent tasks | Plan is linear/sequential | | Multiple specialists needed (review + test + implement) | Single-focus work | | Want maximum parallelism | Simpler mental model preferred | | Large feature with clear phases | Small feature or bug fix |
To trigger swarm execution, say:
"Make a Task list and launch an army of agent swarm subagents to build the plan"
Or explicitly request: "Use swarm mode for this work"
When swarm mode is enabled, the workflow changes:
Create Team
Teammate({ operation: "spawnTeam", team_name: "work-{timestamp}" })
Create Task List with Dependencies
Spawn Specialized Teammates
Task({
team_name: "work-{timestamp}",
name: "implementer",
subagent_type: "general-purpose",
prompt: "Claim implementation tasks, execute, mark complete",
run_in_background: true
})
Task({
team_name: "work-{timestamp}",
name: "tester",
subagent_type: "general-purpose",
prompt: "Claim testing tasks, run tests, mark complete",
run_in_background: true
})
Coordinate and Monitor
Cleanup
Teammate({ operation: "requestShutdown", target_agent_id: "implementer" })
Teammate({ operation: "requestShutdown", target_agent_id: "tester" })
Teammate({ operation: "cleanup" })
See the orchestrating-swarms skill for detailed swarm patterns and best practices.
Note: Swarm mode bypasses the orchestrated execution model (Phase 2). This means no execution session files, no learnings brief accumulation, no STATE.md, and no regression guard. Use swarm mode when speed and parallelism matter more than knowledge compounding. For features where execution learnings are valuable, use the standard orchestrated execution.
systematic-debugging skill for structured root-cause analysis instead of trial-and-errorBefore creating PR, verify:
docs/execution-sessions/Don't use by default. Use reviewer agents only when:
For most features: tests + linting + following patterns is sufficient.
tools
Package one plan execution packet into a compact ticket-local execution packet with parent refs, scope fences, feature-home ownership, and evidence commands. Use when converting plans into local tickets or when execution needs one ticket-sized context pack without the full plan.
tools
Package one plan execution packet into a compact ticket-local execution packet with parent refs, scope fences, feature-home ownership, and evidence commands. Use when converting plans into local tickets or when execution needs one ticket-sized context pack without the full plan.
testing
Run a deep adversarial review of plans and architecture before implementation. Use when validating strategy docs, contracts, roadmaps, and competitive positioning with scored findings and prioritized recommendations.
testing
Run a deep adversarial review of plans and architecture before implementation. Use when validating strategy docs, contracts, roadmaps, and competitive positioning with scored findings and prioritized recommendations.