Task Path Optimization
Concept of the skill
Task path optimization is route planning before execution: classify the task shape, choose the lightest sufficient approach, sequence dependencies, isolate exploration when context would get polluted, and switch strategy after repeated failure instead of pushing harder on a bad path.
Concept Card
What it is: Task path optimization is the pre-execution discipline of choosing how to work before starting the work. It classifies task shape, risk, uncertainty, dependency structure, context cost, and review needs so the agent picks a direct edit, lightweight plan, exploration pass, parallel split, orchestrator-worker flow, evaluator-optimizer loop, or fresh-context recovery.
Mental model: Treat the task as a route-planning problem. The primitives are scope clarity, file certainty, dependency graph, risk/reversibility, context budget, parallelism, and failure history. The route is only optimal if its overhead is proportional to the work.
Why it exists: Agents waste time in two opposite ways: coding immediately when they do not understand the surface, or creating elaborate plans for one-line work. Naming the path decision prevents both failure modes and makes escalation deliberate.
What it is NOT: It is not task execution, debugging, tool-call optimization, Linear task lifecycle management, or architecture decision recording. It chooses the work path; adjacent skills perform the work, investigate failures, manage tasks, or document durable decisions.
Adjacent concepts: task-lifecycle shapes work into tasks, task-execution executes a chosen plan, codebase-search handles exploration mechanics, tool-call-strategy optimizes individual calls, and diagnosis/troubleshooting handle observed failures.
One-line analogy: Task path optimization is choosing whether you need no map, a route preview, a scout, a convoy, or a fresh start before the trip begins.
Common misconception: More planning is not automatically safer. The best path is the smallest sufficient path that still handles the task's actual uncertainty and risk.
Domain Context
What is this skill? This skill provides decision frameworks for choosing the optimal execution path before starting work: plan-vs-act gates, agent architecture selection (chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope management heuristics, critical-path analysis across task networks, and context budget awareness. Use when deciding how to approach a task (plan first vs act immediately), decomposing complex work into parallelizable subtasks, choosing between subagent patterns, or when a task has failed twice and needs a fresh approach. Do NOT use for executing the chosen plan (use task-execution), debugging failures (use troubleshooting or diagnosis), or tool-level efficiency (use tool-call-strategy).
Key Files
| File |
Purpose |
.claude/commands/workflow/experiment.md |
Sequential Verify -> Design -> Re-verify workflow; concrete prompt-chaining example. |
scripts/model/model-router.js |
Live routing surface that classifies task text and labels into model lanes. |
scripts/loop/dispatch-solver.js |
One-shot and wave dispatch surface; shows background dispatch and dependency-wave execution. |
scripts/task/task-helpers.js |
Queue, wave, effort, prompt, AC, packet, and continuation helpers used by task workflows. |
scripts/loop/dispatch-loop.sh |
Parallel loop dispatch surface with status, budget gates, steering, and harvest behavior. |
scripts/agent/spawn-batch.sh |
Concurrency-limited batch spawner; documents reliability tradeoffs as agent count rises. |
.claude/agents/task-manager.md |
Manage-tier delegation agent; concrete orchestrator-worker handoff contract. |
scripts/analytics/session-scorecard.js |
Local measurement surface for tool efficiency, context discipline, verification, handoff, and session health. |
Coverage
Decision frameworks for choosing the optimal execution path: complexity-first triage, plan-vs-act gates, five agent architecture patterns (prompt chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope management heuristics, critical-path analysis, context budget awareness, recovery from failed approaches, and the Writer/Reviewer pattern for high-risk quality assurance.
Philosophy of the skill
The shortest path between a problem statement and a working solution is rarely a straight line, but it is always a deliberate choice. Agents default to "start coding immediately" or "plan everything exhaustively" — both waste time depending on context. This skill exists because the decision of how to approach a task is separate from the act of executing it, and getting the approach wrong costs more than the approach selection itself. A 30-second triage that correctly identifies "act immediately" saves 10 minutes of unnecessary planning. A 2-minute plan on a complex task prevents 30 minutes of wrong-direction implementation. The key insight: match the weight of your approach to the weight of the problem.
Authority: Owns the pre-execution decision: what approach to use, how to decompose work, when to parallelize, when to start over. Defers to task-execution for executing the chosen plan and tool-call-strategy for individual tool call efficiency.
1. Complexity-First Triage
Before touching any code, assess task complexity to determine approach weight.
| Complexity Signal |
Approach |
Rationale |
| Can describe the diff in one sentence |
Act immediately |
Planning overhead exceeds implementation cost |
| Single file, clear scope, known pattern |
Act with lightweight verification |
Low risk of cascading side effects |
| Multiple files, unclear interfaces |
Plan first, then implement |
Need to understand module boundaries before committing |
| Unfamiliar codebase area, architectural implications |
Explore, plan, implement (3-phase) |
Understanding precedes strategy |
| Open-ended or ambiguous requirements |
Clarify, then plan |
Wrong problem = wasted work regardless of execution quality |
| Previously failed twice |
Clear context, fresh approach |
Context pollution degrades performance geometrically |
Rule: If you could describe the diff in one sentence, skip the plan. If you can't name the files you'll change, you're not ready to plan — you need to explore first. The concrete exploration paths are: task-researcher (key-files + RIPER sections), codebase-search (Glob/Grep/Read decision tree), and the RIPER mode escalation path (Read → Identify → Plan → Execute → Review) documented in task-researcher. Use task-researcher as the subagent when exploration should happen in an isolated context.
2. The Plan-vs-Act Decision Gate
Is the task scope clear and the fix small?
YES --> Act immediately (commit to execution path)
NO --> Is the execution path predictable (known files, known pattern)?
YES --> Lightweight plan (list files + changes, then execute)
NO --> Is it exploratory or research-oriented?
YES --> Explore-Plan-Execute (3-phase, use RIPER)
NO --> Orchestrator-Worker (dynamic decomposition with subagents)
Decision signals
| Signal |
Points toward ACT |
Points toward PLAN |
| Number of files |
1-2 files |
3+ files |
| Pattern exists in codebase |
Yes, copy from neighbor |
No precedent |
| Risk of regression |
Low (isolated change) |
High (shared boundary) |
| Reversibility |
Easy (one commit to revert) |
Hard (schema migration, API contract) |
| Ambiguity |
Clear requirement |
Ambiguous or conflicting signals |
| Prior failures on this task |
0 |
1+ (need fresh strategy) |
3. Five Agent Architecture Patterns
Choose the right pattern for the task shape. Anthropic's "Building effective agents" recommends starting with simple composable patterns and adding complexity only when it improves outcomes.
| Pattern |
Status In This Repo |
Task Shape |
When to Use |
Concrete repo anchor |
| Prompt Chaining |
Conceptual framing — present as command/phase design, not a named runtime primitive |
Sequential fixed steps |
Clear stages where output of A feeds B |
/experiment Phase 1 -> 2 -> 3 in .claude/commands/workflow/experiment.md |
| Routing |
Live infra |
Distinct categories need different treatment |
Input classification determines handler |
scripts/model/model-router.js, scripts/loop/dispatch-solver.js, scripts/task/task-helpers.js |
| Parallelization |
Live infra |
Independent subtasks or multi-perspective |
Work can be sectioned; voting improves confidence |
scripts/loop/dispatch-loop.sh, scripts/agent/spawn-batch.sh, parallel tool execution |
| Orchestrator-Worker |
Live infra |
Subtasks can't be predicted in advance |
Dynamic decomposition needed |
.claude/agents/task-manager.md, /workflow/manage, scripts/task/task-helpers.js |
| Evaluator-Optimizer |
Mixed — live in a few concrete loops, otherwise a conceptual quality pattern |
Iterative refinement measurably improves output |
Quality is gradable and loopable |
/experiment judge flow in .claude/commands/workflow/experiment.md; task-manager critic gate references task-critic.js even though that implementation is not currently present in this repo |
Foundational principle: Start with the simplest pattern that could work. Only increase complexity when the simpler pattern demonstrably fails.
How to read the status column
- Live infra means the pattern exists as a concrete script, command, or runtime surface in this repo today.
- Conceptual framing means the pattern is useful for thinking about execution shape, but it is not exposed as a named shared runtime primitive.
- Mixed means part of the pattern is implemented in a specific workflow, while the generalized pattern is still guidance rather than reusable infrastructure.
Pattern selection flowchart
Are all steps known in advance?
YES --> Are they independent?
YES --> Parallelization
NO --> Prompt Chaining
NO --> Does the task have distinct categories?
YES --> Routing
NO --> Can quality be measured and iterated?
YES --> Evaluator-Optimizer
NO --> Orchestrator-Worker
4. Scope Management Heuristics
Scope creep is the primary cause of task failure in agent workflows. These rules prevent it.
Before starting
- Name the deliverable. One sentence: "When this is done, [X] will work."
- List the files. If you can't name the files, you need exploration, not execution. Use
task-researcher (subagent) or codebase-search (direct Glob/Grep/Read) to explore; RIPER mode (task-researcher key-files → overview) is the structured escalation path.
- Set the boundary. "I will NOT touch [Y] even if I see issues."
- Define success evidence. A command, test, or screenshot that proves completion.
During execution
- One task per context. Never mix unrelated work in the same session.
- Adjacent issues go to Linear. If you find a bug while fixing another bug, file it — don't fix it now unless it blocks you.
- Two-failure rule. After two failed corrections on the same approach, stop. The approach is wrong, not the details. Clear context, rethink strategy.
- Context pollution compounds. Each failed attempt adds noise. After the two-failure threshold,
/clear and restart with lessons learned baked into the initial prompt.
After completion
- Verify against the original deliverable. Not "does the code work" but "does it satisfy the one-sentence deliverable from step 1."
- Capture the path. If the optimal path was non-obvious, document it for future agents.
5. Critical Path Analysis
When a task decomposes into subtasks, identify the critical path — the longest chain of dependent subtasks that determines total completion time.
Dependency classification
| Dependency Type |
Can Parallelize? |
Example |
| Data dependency (A's output feeds B) |
No |
Migration must complete before seed script |
| Resource dependency (A and B need same file) |
No (merge conflicts) |
Two features modifying the same component |
| Order dependency (A must run before B by convention) |
Maybe |
Tests after implementation (but lint can run in parallel) |
| Independent (no shared state) |
Yes |
Frontend and backend changes for the same feature |
Parallelization decision
For each pair of subtasks:
Do they share any files?
YES --> Sequential (or use worktree isolation)
NO --> Do they share state (DB, env, running server)?
YES --> Sequential
NO --> Parallel (use subagents)
Optimal ordering rules
- Start with the riskiest subtask. If it fails, you learn early before investing in dependent work.
- Parallelize verification. Typecheck, lint, and test can almost always run in parallel.
- Front-load exploration. Read and understand before writing — reduces wrong-direction time.
- Batch similar changes. Five similar file edits are faster as one scripted batch than five individual tool calls.
6. Context Budget Awareness
Context is a finite resource. Every file read, every command output, every tool call result consumes it. Performance degrades as context fills.
Context-efficient patterns
| Pattern |
Why It Saves Context |
| Grep before Read |
Matching lines only vs entire file |
| Subagents for exploration |
Explore in separate context, report back summary |
| Scripts for bulk operations |
One command result vs N individual results |
/clear between unrelated tasks |
Prevents cross-contamination |
| Targeted reads (offset + limit) |
Read 50 lines around the function, not the 2000-line file |
Context-expensive anti-patterns
| Anti-Pattern |
Context Cost |
Fix |
| Reading entire files to find one function |
High |
Grep for function name, read only that section |
| Keeping failed approach context |
Compounds |
/clear after two failures |
| Running full test suite output in context |
Very high |
Run in background, check exit code |
| Exploring without scope |
Unbounded |
Set a file/directory boundary before exploring |
7. Recovery: When the Current Approach Fails
Not every approach works. Recognizing failure early and switching cleanly is a skill.
Failure signals
- Same error after two different fix attempts
- Fix introduces new failures in unrelated areas
- Realization that the mental model of the system was wrong
- Context is polluted with multiple failed approaches
Recovery protocol
- Stop. Do not make a third attempt on the same approach.
- Commit or stash any partial progress worth keeping.
- Clear context (
/clear or spawn a fresh subagent).
- Write a one-paragraph brief that includes: what was tried, why it failed, what the new hypothesis is.
- Start the new approach from the brief, not from memory of the failed attempt.
The Writer/Reviewer pattern
For high-stakes tasks, use two separate contexts:
- Writer context: Implements the solution
- Reviewer context: Reviews with fresh eyes (no implementation bias)
This pattern catches errors that the writer's context has normalized. Use it for security changes, architectural decisions, and any task where correctness matters more than speed.
8. The METR Finding
External research from METR (2025) reported that experienced open-source developers in its randomized controlled trial took 19% longer with early-2025 AI tools, despite expecting a 24% speedup. Treat that result as a caution about hidden coordination, review, and quality-standard overhead — not as a measured truth about this repo's own agent system, and not as a universal claim that AI tools slow all developers.
For repo-specific overhead, check local measurement surfaces instead of borrowing the METR number as if it were native telemetry:
scripts/analytics/session-scorecard.js and the generated session score artifacts
scripts/model/usage-collector.js and USAGE.md
- task-level runtime evidence such as verification receipts, wrap summaries, and per-command loop outcomes
Implication for this skill: The optimal path is NOT "let the agent do everything." It is knowing:
- When to let the agent work autonomously (clear scope, known pattern)
- When to decompose into smaller agent-sized chunks (complex but parallelizable)
- When to take over manually (agent is looping, context is polluted)
- When to use the agent as a reviewer rather than an implementer
9. Source Notes
| Claim |
Evidence |
| Use simple composable agent patterns before adding complexity. |
Anthropic, "Building effective agents" (2024): start with simple solutions and add agentic complexity only when needed. |
| Prompt chaining, routing, parallelization, orchestrator-workers, and evaluator-optimizer are standard agentic workflow patterns. |
Anthropic, "Building effective agents" sections on workflow patterns. |
| Early-2025 AI slowed experienced open-source developers in one RCT by 19% despite expected speedup. |
METR, "Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity" (2025). |
| Local overhead should be measured locally, not inferred from external studies. |
scripts/analytics/session-scorecard.js and scripts/model/usage-collector.js provide repo-local measurement surfaces. |
Verification
After applying this skill, verify:
Do NOT Use When
| Instead of this skill |
Use |
Why |
| Executing a known plan with clear subtasks |
task-execution |
This skill chooses the approach; task-execution runs it |
| Debugging a specific failure |
troubleshooting or diagnosis |
Debugging is reactive investigation, not approach selection |
| Optimizing individual tool calls |
tool-call-strategy |
This skill operates at the task level; tool-call-strategy operates at the call level |
| Breaking work into Linear tasks |
task-lifecycle or task-sizing |
This skill is about execution strategy, not project management |
| Choosing between technical architectures |
adr |
ADRs are about permanent architectural decisions, not ephemeral execution paths |
Version 1.0.0 — 2026-04-02. Based on Anthropic's "Building Effective Agents" research, METR efficiency findings, and repo-specific execution patterns.
Skill Graph context
Classification
- Subject:
software-engineering-method
- Public:
true
- Scope: Choosing the optimal execution path before starting work — plan-vs-act gates, agent-architecture selection (chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope-management heuristics, critical-path analysis across task networks, and context-budget awareness, including the fresh-approach reset when a task has failed twice. Portable across any agentic execution; principle-grounded, not repo-bound. Excludes executing the chosen plan (task-execution), debugging failures (troubleshooting, diagnosis), and tool-level efficiency (tool-call-strategy).
When to use
- this task has failed twice, I need a fresh approach not another retry on the same path
- what is the shortest path to a solution here, plan vs act for this task
- assess this task's complexity and pick the lightest sufficient approach before I start
- is this work simple enough to just act, or should I plan the execution path first
- Triggers:
task-path-optimization, execution-strategy, approach-selection
Not for
- reduce the number of tool calls in this read-heavy step
- troubleshoot why the deployment keeps timing out
- execute the implementation plan we already agreed on
Related skills
- Verify with:
code-review
- Related:
prioritization, context-engineering, tool-call-strategy, test-driven-development
Concept
- Mental model: Task path optimization is route planning before execution: classify the task shape, choose the lightest sufficient approach, sequence dependencies, isolate exploration when context would get polluted, and switch strategy after repeated failure instead of pushing harder on a bad path.
- Purpose: This skill prevents agents from either coding too soon on ambiguous work or over-planning simple work. It makes the execution path an explicit decision so planning, delegation, parallelization, review, and context reset are used only when the task shape justifies them.
- Boundary: This skill chooses the approach before execution. It does not execute the implementation, debug a concrete failure, optimize individual tool calls, manage Linear issue lifecycle, or record durable architecture decisions.
- Analogy: Task path optimization is like choosing a route before a trip: walking across the street needs no map, crossing a city needs traffic awareness, and crossing a mountain range needs checkpoints and fallback routes.
- Common misconception: The common mistake is treating more process as safer. The safest path is the smallest path that still handles ambiguity, dependency, risk, and verification.
Keywords
optimal path, plan vs act, task decomposition, task complexity, lightest sufficient approach, agent architecture, scope management, shortest path to solution, failed twice, fresh approach
1---2name: task-path-optimization3description: This skill provides decision frameworks for choosing the optimal execution path before starting work: plan-vs-act gates, agent architecture selection (chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope management heuristics, critical-path analysis across task networks, and context budget awareness. Use when deciding how to approach a task (plan first vs act immediately), decomposing complex work into parallelizable subtasks, choosing between subagent patterns, or when a task has failed twice and needs a fresh approach. Do NOT use for executing the chosen plan (use task-execution), debugging failures (use troubleshooting or diagnosis), or tool-level efficiency (use tool-call-strategy). Do NOT use for reduce the number of tool calls in this read-heavy step. Do NOT use for troubleshoot why the deployment keeps timing out. Do NOT use for execute the implementation plan we already agreed on.4---56# Task Path Optimization78## Concept of the skill910Task path optimization is route planning before execution: classify the task shape, choose the lightest sufficient approach, sequence dependencies, isolate exploration when context would get polluted, and switch strategy after repeated failure instead of pushing harder on a bad path.1112## Concept Card1314**What it is:** Task path optimization is the pre-execution discipline of choosing how to work before starting the work. It classifies task shape, risk, uncertainty, dependency structure, context cost, and review needs so the agent picks a direct edit, lightweight plan, exploration pass, parallel split, orchestrator-worker flow, evaluator-optimizer loop, or fresh-context recovery.1516**Mental model:** Treat the task as a route-planning problem. The primitives are scope clarity, file certainty, dependency graph, risk/reversibility, context budget, parallelism, and failure history. The route is only optimal if its overhead is proportional to the work.1718**Why it exists:** Agents waste time in two opposite ways: coding immediately when they do not understand the surface, or creating elaborate plans for one-line work. Naming the path decision prevents both failure modes and makes escalation deliberate.1920**What it is NOT:** It is not task execution, debugging, tool-call optimization, Linear task lifecycle management, or architecture decision recording. It chooses the work path; adjacent skills perform the work, investigate failures, manage tasks, or document durable decisions.2122**Adjacent concepts:** `task-lifecycle` shapes work into tasks, `task-execution` executes a chosen plan, `codebase-search` handles exploration mechanics, `tool-call-strategy` optimizes individual calls, and `diagnosis`/`troubleshooting` handle observed failures.2324**One-line analogy:** Task path optimization is choosing whether you need no map, a route preview, a scout, a convoy, or a fresh start before the trip begins.2526**Common misconception:** More planning is not automatically safer. The best path is the smallest sufficient path that still handles the task's actual uncertainty and risk.2728## Domain Context2930**What is this skill?** This skill provides decision frameworks for choosing the optimal execution path before starting work: plan-vs-act gates, agent architecture selection (chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope management heuristics, critical-path analysis across task networks, and context budget awareness. Use when deciding how to approach a task (plan first vs act immediately), decomposing complex work into parallelizable subtasks, choosing between subagent patterns, or when a task has failed twice and needs a fresh approach. Do NOT use for executing the chosen plan (use task-execution), debugging failures (use troubleshooting or diagnosis), or tool-level efficiency (use tool-call-strategy).3132## Key Files3334| File | Purpose |35|---|---|36| `.claude/commands/workflow/experiment.md` | Sequential Verify -> Design -> Re-verify workflow; concrete prompt-chaining example. |37| `scripts/model/model-router.js` | Live routing surface that classifies task text and labels into model lanes. |38| `scripts/loop/dispatch-solver.js` | One-shot and wave dispatch surface; shows background dispatch and dependency-wave execution. |39| `scripts/task/task-helpers.js` | Queue, wave, effort, prompt, AC, packet, and continuation helpers used by task workflows. |40| `scripts/loop/dispatch-loop.sh` | Parallel loop dispatch surface with status, budget gates, steering, and harvest behavior. |41| `scripts/agent/spawn-batch.sh` | Concurrency-limited batch spawner; documents reliability tradeoffs as agent count rises. |42| `.claude/agents/task-manager.md` | Manage-tier delegation agent; concrete orchestrator-worker handoff contract. |43| `scripts/analytics/session-scorecard.js` | Local measurement surface for tool efficiency, context discipline, verification, handoff, and session health. |4445## Coverage4647Decision frameworks for choosing the optimal execution path: complexity-first triage, plan-vs-act gates, five agent architecture patterns (prompt chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope management heuristics, critical-path analysis, context budget awareness, recovery from failed approaches, and the Writer/Reviewer pattern for high-risk quality assurance.4849## Philosophy of the skill50The shortest path between a problem statement and a working solution is rarely a straight line, but it is always a deliberate choice. Agents default to "start coding immediately" or "plan everything exhaustively" — both waste time depending on context. This skill exists because the decision of *how* to approach a task is separate from the act of executing it, and getting the approach wrong costs more than the approach selection itself. A 30-second triage that correctly identifies "act immediately" saves 10 minutes of unnecessary planning. A 2-minute plan on a complex task prevents 30 minutes of wrong-direction implementation. The key insight: match the weight of your approach to the weight of the problem.5152> **Authority:** Owns the pre-execution decision: what approach to use, how to decompose work, when to parallelize, when to start over. Defers to `task-execution` for executing the chosen plan and `tool-call-strategy` for individual tool call efficiency.5354---5556## 1. Complexity-First Triage5758Before touching any code, assess task complexity to determine approach weight.5960| Complexity Signal | Approach | Rationale |61|---|---|---|62| Can describe the diff in one sentence | **Act immediately** | Planning overhead exceeds implementation cost |63| Single file, clear scope, known pattern | **Act with lightweight verification** | Low risk of cascading side effects |64| Multiple files, unclear interfaces | **Plan first, then implement** | Need to understand module boundaries before committing |65| Unfamiliar codebase area, architectural implications | **Explore, plan, implement** (3-phase) | Understanding precedes strategy |66| Open-ended or ambiguous requirements | **Clarify, then plan** | Wrong problem = wasted work regardless of execution quality |67| Previously failed twice | **Clear context, fresh approach** | Context pollution degrades performance geometrically |6869**Rule:** If you could describe the diff in one sentence, skip the plan. If you can't name the files you'll change, you're not ready to plan — you need to explore first. The concrete exploration paths are: `task-researcher` (key-files + RIPER sections), `codebase-search` (Glob/Grep/Read decision tree), and the RIPER mode escalation path (Read → Identify → Plan → Execute → Review) documented in `task-researcher`. Use `task-researcher` as the subagent when exploration should happen in an isolated context.7071---7273## 2. The Plan-vs-Act Decision Gate7475```76Is the task scope clear and the fix small?77 YES --> Act immediately (commit to execution path)78 NO --> Is the execution path predictable (known files, known pattern)?79 YES --> Lightweight plan (list files + changes, then execute)80 NO --> Is it exploratory or research-oriented?81 YES --> Explore-Plan-Execute (3-phase, use RIPER)82 NO --> Orchestrator-Worker (dynamic decomposition with subagents)83```8485### Decision signals8687| Signal | Points toward ACT | Points toward PLAN |88|---|---|---|89| Number of files | 1-2 files | 3+ files |90| Pattern exists in codebase | Yes, copy from neighbor | No precedent |91| Risk of regression | Low (isolated change) | High (shared boundary) |92| Reversibility | Easy (one commit to revert) | Hard (schema migration, API contract) |93| Ambiguity | Clear requirement | Ambiguous or conflicting signals |94| Prior failures on this task | 0 | 1+ (need fresh strategy) |9596---9798## 3. Five Agent Architecture Patterns99100Choose the right pattern for the task shape. Anthropic's "Building effective agents" recommends starting with simple composable patterns and adding complexity only when it improves outcomes.101102| Pattern | Status In This Repo | Task Shape | When to Use | Concrete repo anchor |103|---|---|---|---|---|104| **Prompt Chaining** | **Conceptual framing** — present as command/phase design, not a named runtime primitive | Sequential fixed steps | Clear stages where output of A feeds B | `/experiment` Phase 1 -> 2 -> 3 in `.claude/commands/workflow/experiment.md` |105| **Routing** | **Live infra** | Distinct categories need different treatment | Input classification determines handler | `scripts/model/model-router.js`, `scripts/loop/dispatch-solver.js`, `scripts/task/task-helpers.js` |106| **Parallelization** | **Live infra** | Independent subtasks or multi-perspective | Work can be sectioned; voting improves confidence | `scripts/loop/dispatch-loop.sh`, `scripts/agent/spawn-batch.sh`, parallel tool execution |107| **Orchestrator-Worker** | **Live infra** | Subtasks can't be predicted in advance | Dynamic decomposition needed | `.claude/agents/task-manager.md`, `/workflow/manage`, `scripts/task/task-helpers.js` |108| **Evaluator-Optimizer** | **Mixed** — live in a few concrete loops, otherwise a conceptual quality pattern | Iterative refinement measurably improves output | Quality is gradable and loopable | `/experiment` judge flow in `.claude/commands/workflow/experiment.md`; task-manager critic gate references `task-critic.js` even though that implementation is not currently present in this repo |109110**Foundational principle:** Start with the simplest pattern that could work. Only increase complexity when the simpler pattern demonstrably fails.111112### How to read the status column113114- **Live infra** means the pattern exists as a concrete script, command, or runtime surface in this repo today.115- **Conceptual framing** means the pattern is useful for thinking about execution shape, but it is not exposed as a named shared runtime primitive.116- **Mixed** means part of the pattern is implemented in a specific workflow, while the generalized pattern is still guidance rather than reusable infrastructure.117118### Pattern selection flowchart119120```121Are all steps known in advance?122 YES --> Are they independent?123 YES --> Parallelization124 NO --> Prompt Chaining125 NO --> Does the task have distinct categories?126 YES --> Routing127 NO --> Can quality be measured and iterated?128 YES --> Evaluator-Optimizer129 NO --> Orchestrator-Worker130```131132---133134## 4. Scope Management Heuristics135136Scope creep is the primary cause of task failure in agent workflows. These rules prevent it.137138### Before starting1391401. **Name the deliverable.** One sentence: "When this is done, [X] will work."1412. **List the files.** If you can't name the files, you need exploration, not execution. Use `task-researcher` (subagent) or `codebase-search` (direct Glob/Grep/Read) to explore; RIPER mode (`task-researcher` key-files → overview) is the structured escalation path.1423. **Set the boundary.** "I will NOT touch [Y] even if I see issues."1434. **Define success evidence.** A command, test, or screenshot that proves completion.144145### During execution1461475. **One task per context.** Never mix unrelated work in the same session.1486. **Adjacent issues go to Linear.** If you find a bug while fixing another bug, file it — don't fix it now unless it blocks you.1497. **Two-failure rule.** After two failed corrections on the same approach, stop. The approach is wrong, not the details. Clear context, rethink strategy.1508. **Context pollution compounds.** Each failed attempt adds noise. After the two-failure threshold, `/clear` and restart with lessons learned baked into the initial prompt.151152### After completion1531549. **Verify against the original deliverable.** Not "does the code work" but "does it satisfy the one-sentence deliverable from step 1."15510. **Capture the path.** If the optimal path was non-obvious, document it for future agents.156157---158159## 5. Critical Path Analysis160161When a task decomposes into subtasks, identify the critical path — the longest chain of dependent subtasks that determines total completion time.162163### Dependency classification164165| Dependency Type | Can Parallelize? | Example |166|---|---|---|167| **Data dependency** (A's output feeds B) | No | Migration must complete before seed script |168| **Resource dependency** (A and B need same file) | No (merge conflicts) | Two features modifying the same component |169| **Order dependency** (A must run before B by convention) | Maybe | Tests after implementation (but lint can run in parallel) |170| **Independent** (no shared state) | Yes | Frontend and backend changes for the same feature |171172### Parallelization decision173174```175For each pair of subtasks:176 Do they share any files?177 YES --> Sequential (or use worktree isolation)178 NO --> Do they share state (DB, env, running server)?179 YES --> Sequential180 NO --> Parallel (use subagents)181```182183### Optimal ordering rules1841851. **Start with the riskiest subtask.** If it fails, you learn early before investing in dependent work.1862. **Parallelize verification.** Typecheck, lint, and test can almost always run in parallel.1873. **Front-load exploration.** Read and understand before writing — reduces wrong-direction time.1884. **Batch similar changes.** Five similar file edits are faster as one scripted batch than five individual tool calls.189190---191192## 6. Context Budget Awareness193194Context is a finite resource. Every file read, every command output, every tool call result consumes it. Performance degrades as context fills.195196### Context-efficient patterns197198| Pattern | Why It Saves Context |199|---|---|200| Grep before Read | Matching lines only vs entire file |201| Subagents for exploration | Explore in separate context, report back summary |202| Scripts for bulk operations | One command result vs N individual results |203| `/clear` between unrelated tasks | Prevents cross-contamination |204| Targeted reads (offset + limit) | Read 50 lines around the function, not the 2000-line file |205206### Context-expensive anti-patterns207208| Anti-Pattern | Context Cost | Fix |209|---|---|---|210| Reading entire files to find one function | High | Grep for function name, read only that section |211| Keeping failed approach context | Compounds | `/clear` after two failures |212| Running full test suite output in context | Very high | Run in background, check exit code |213| Exploring without scope | Unbounded | Set a file/directory boundary before exploring |214215---216217## 7. Recovery: When the Current Approach Fails218219Not every approach works. Recognizing failure early and switching cleanly is a skill.220221### Failure signals222223- Same error after two different fix attempts224- Fix introduces new failures in unrelated areas225- Realization that the mental model of the system was wrong226- Context is polluted with multiple failed approaches227228### Recovery protocol2292301. **Stop.** Do not make a third attempt on the same approach.2312. **Commit or stash** any partial progress worth keeping.2323. **Clear context** (`/clear` or spawn a fresh subagent).2334. **Write a one-paragraph brief** that includes: what was tried, why it failed, what the new hypothesis is.2345. **Start the new approach** from the brief, not from memory of the failed attempt.235236### The Writer/Reviewer pattern237238For high-stakes tasks, use two separate contexts:239- **Writer context:** Implements the solution240- **Reviewer context:** Reviews with fresh eyes (no implementation bias)241242This pattern catches errors that the writer's context has normalized. Use it for security changes, architectural decisions, and any task where correctness matters more than speed.243244---245246## 8. The METR Finding247248External research from METR (2025) reported that experienced open-source developers in its randomized controlled trial took 19% longer with early-2025 AI tools, despite expecting a 24% speedup. Treat that result as a caution about hidden coordination, review, and quality-standard overhead — not as a measured truth about this repo's own agent system, and not as a universal claim that AI tools slow all developers.249250For repo-specific overhead, check local measurement surfaces instead of borrowing the METR number as if it were native telemetry:251- `scripts/analytics/session-scorecard.js` and the generated session score artifacts252- `scripts/model/usage-collector.js` and `USAGE.md`253- task-level runtime evidence such as verification receipts, wrap summaries, and per-command loop outcomes254255**Implication for this skill:** The optimal path is NOT "let the agent do everything." It is knowing:256- When to let the agent work autonomously (clear scope, known pattern)257- When to decompose into smaller agent-sized chunks (complex but parallelizable)258- When to take over manually (agent is looping, context is polluted)259- When to use the agent as a reviewer rather than an implementer260261## 9. Source Notes262263| Claim | Evidence |264|---|---|265| Use simple composable agent patterns before adding complexity. | Anthropic, "Building effective agents" (2024): start with simple solutions and add agentic complexity only when needed. |266| Prompt chaining, routing, parallelization, orchestrator-workers, and evaluator-optimizer are standard agentic workflow patterns. | Anthropic, "Building effective agents" sections on workflow patterns. |267| Early-2025 AI slowed experienced open-source developers in one RCT by 19% despite expected speedup. | METR, "Measuring the Impact of Early-2025 AI on Experienced Open-Source Developer Productivity" (2025). |268| Local overhead should be measured locally, not inferred from external studies. | `scripts/analytics/session-scorecard.js` and `scripts/model/usage-collector.js` provide repo-local measurement surfaces. |269270---271272## Verification273274After applying this skill, verify:275- [ ] I assessed task complexity before choosing an approach276- [ ] I can name the specific files I will change277- [ ] I defined the deliverable in one sentence278- [ ] I chose the simplest agent pattern that fits the task shape279- [ ] I identified parallelizable subtasks and ran them concurrently where possible280- [ ] I did not mix unrelated work in the same context281- [ ] If an approach failed twice, I cleared context and started fresh282283## Do NOT Use When284285| Instead of this skill | Use | Why |286|---|---|---|287| Executing a known plan with clear subtasks | `task-execution` | This skill chooses the approach; task-execution runs it |288| Debugging a specific failure | `troubleshooting` or `diagnosis` | Debugging is reactive investigation, not approach selection |289| Optimizing individual tool calls | `tool-call-strategy` | This skill operates at the task level; tool-call-strategy operates at the call level |290| Breaking work into Linear tasks | `task-lifecycle` or `task-sizing` | This skill is about execution strategy, not project management |291| Choosing between technical architectures | `adr` | ADRs are about permanent architectural decisions, not ephemeral execution paths |292293---294295*Version 1.0.0 — 2026-04-02. Based on Anthropic's "Building Effective Agents" research, METR efficiency findings, and repo-specific execution patterns.*296297## Skill Graph context298299<!-- skill-graph-context:start (generated — do not edit by hand) -->300301**Classification**302- Subject: `software-engineering-method`303- Public: `true`304- Scope: Choosing the optimal execution path before starting work — plan-vs-act gates, agent-architecture selection (chaining, routing, parallelization, orchestrator-worker, evaluator-optimizer), scope-management heuristics, critical-path analysis across task networks, and context-budget awareness, including the fresh-approach reset when a task has failed twice. Portable across any agentic execution; principle-grounded, not repo-bound. Excludes executing the chosen plan (task-execution), debugging failures (troubleshooting, diagnosis), and tool-level efficiency (tool-call-strategy).305306**When to use**307- this task has failed twice, I need a fresh approach not another retry on the same path308- what is the shortest path to a solution here, plan vs act for this task309- assess this task's complexity and pick the lightest sufficient approach before I start310- is this work simple enough to just act, or should I plan the execution path first311- Triggers: `task-path-optimization`, `execution-strategy`, `approach-selection`312313**Not for**314- reduce the number of tool calls in this read-heavy step315- troubleshoot why the deployment keeps timing out316- execute the implementation plan we already agreed on317318**Related skills**319- Verify with: `code-review`320- Related: `prioritization`, `context-engineering`, `tool-call-strategy`, `test-driven-development`321322**Concept**323- Mental model: Task path optimization is route planning before execution: classify the task shape, choose the lightest sufficient approach, sequence dependencies, isolate exploration when context would get polluted, and switch strategy after repeated failure instead of pushing harder on a bad path.324- Purpose: This skill prevents agents from either coding too soon on ambiguous work or over-planning simple work. It makes the execution path an explicit decision so planning, delegation, parallelization, review, and context reset are used only when the task shape justifies them.325- Boundary: This skill chooses the approach before execution. It does not execute the implementation, debug a concrete failure, optimize individual tool calls, manage Linear issue lifecycle, or record durable architecture decisions.326- Analogy: Task path optimization is like choosing a route before a trip: walking across the street needs no map, crossing a city needs traffic awareness, and crossing a mountain range needs checkpoints and fallback routes.327- Common misconception: The common mistake is treating more process as safer. The safest path is the smallest path that still handles ambiguity, dependency, risk, and verification.328329**Keywords**330- `optimal path`, `plan vs act`, `task decomposition`, `task complexity`, `lightest sufficient approach`, `agent architecture`, `scope management`, `shortest path to solution`, `failed twice`, `fresh approach`331332<!-- skill-graph-context:end -->