Verified SOP & TutorialAudited Score 98/100

The Complete Production SOP: How to Deploy and Run Plan-and-Solve Hierarchical Task Decomposition in Autonomous AI Agents

Step-by-step SOP to install and run Plan-and-Solve Hierarchical Task Decomposition in Codex, Claude Code, and Cursor. Includes verified prompts and DAG workflows.

Target Runtimes:codexclaude-codecursorwindsurf
5 min read • Updated for 2026

Technical Overview & Architectural Context

Autonomous coding agents frequently suffer from greedy execution bias when handed complex, multi-file engineering challenges. Without an explicit planning constraint, LLMs immediately generate and mutate code files on the first step before discovering circular dependencies, missing database schema fields, or contradictory interface contracts three layers deep. This reactive loop exhausts context tokens through repeated rollbacks and causes hallucinated patches that break existing system architectures. Plan-and-Solve Hierarchical Task Decomposition enforces a hard boundary between the architectural planning phase and concrete code execution. By requiring the agent to synthesize an initial dependency-ordered Directed Acyclic Graph (DAG) before writing a single byte to disk, this skill neutralizes execution drift. Each subtask is linked to strict prerequisite gates (e.g., database migration -> ORM entities -> repository interface -> HTTP controllers). Furthermore, the skill equips agents with a formal replanning mechanism: whenever a subtask triggers a compiler error or unresolvable test regression, the agent pauses instead of thrashing, updates the DAG state dynamically, and recalculates downstream subtasks. This converts erratic trial-and-error agent behavior into deterministic, verifiable engineering progress.

Prerequisites & Environment Requirements

Codex Desktop, Claude Code CLI, Cursor, or Windsurf installed and configured with workspace access
Node.js 20+ or Python 3.10+ configured in the local development sandbox
Git 2.40+ initialized with clean working directory before autonomous runs

Verified Search Intents & Long-Tail Queries Solved

SEO Audit Score: 98/100

This operational tutorial is engineered to provide deterministic solutions for these developer search queries:

#install plan-and-solve-decomposition in cursor ide#claude code plan-and-solve-decomposition rules#codex desktop plan-and-solve-decomposition setup tutorial#how to fix plan-and-solve-decomposition agent execution error#deterministic agents agent SOP#plan-and-solve-decomposition sandbox permissions and security score#plan-and-solve-decomposition prompt examples and triggers#dag task decomposition AI agents windsurf#plan and solve hierarchical task decomposition SOP

Step-by-Step Execution Playbook

1

Local Environment Setup & SKILL.md Mounting

Create the local agent skill manifest directory and inject verified procedural rules into your workspace.

Autonomous runtimes parse skills dynamically from canonical project directories such as `.agents/skills` or `.claude/skills`. We mount the raw `SKILL.md` file containing strict frontmatter directives (`fs_write: workspace`, `shell_exec: false`) and deterministic SOP prompts directly into your project tree.

Terminal Command
mkdir -p .agents/skills/plan-and-solve-decomposition && curl -fsSL https://askills.dev/api/skills/plan-and-solve-decomposition/raw -o .agents/skills/plan-and-solve-decomposition/SKILL.md
.agents/skills/plan-and-solve-decomposition/SKILL.md
---
name: "plan-and-solve-decomposition"
description: "Decompose large, complex engineering goals into subtasks before executing single steps."
metadata:
  author: "Wang et al."
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "create execution plan"
  - "decompose large task"
  - "plan and solve engineering request"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Plan-and-Solve Hierarchical Task Decomposition

Separates the planning phase from the execution phase: generating a dependency-ordered directed acyclic graph (DAG) of subtasks, tracking completion state, and dynamically replanning on failures.

## Execution SOP & Rules
1. Always draft the complete numbered plan before modifying any workspace files.
2. Order subtasks based on strict dependency requirements (e.g. schema migration before API handler).
3. Check off completed items incrementally as progress is made.
4. If a subtask fails or hits a blocker, pause to revise the remaining steps rather than blindly forging ahead.
Production Pro-Tip

Place the SKILL.md inside the root repository `.agents/skills` path to allow seamless project-level hot-reloading across Windsurf, Cursor, and Claude Code without restarting your IDE.

Sandbox Gotcha

Ensure `.agents/skills` is tracked in git. If gitignored, cloud agent sandboxes (e.g., GitHub Workspace Agent) will fail to discover the frontmatter triggers.

2

Workspace Runtime Registration & Verification

Link the skill to your agent's system prompt or configuration file depending on the active IDE runtime.

For Claude Code and Codex, point your configuration to read local skill manifests. For Cursor or Windsurf, register the trigger phrases inside your `.cursorrules` or `.windsurfrules` file so the agent automatically delegates complex prompts to the Plan-and-Solve DAG pipeline.

Terminal Command
echo 'Skill: .agents/skills/plan-and-solve-decomposition/SKILL.md' >> .cursorrules
.claude/skills.json
{
  "skills": [
    {
      "name": "plan-and-solve-decomposition",
      "path": ".agents/skills/plan-and-solve-decomposition/SKILL.md",
      "auto_invoke_triggers": [
        "create execution plan",
        "decompose large task",
        "plan and solve engineering request"
      ]
    }
  ]
}
Production Pro-Tip

Keep the auto_invoke triggers exact. When triggers match user input tokens identically, agent orchestrators bypass expensive semantic router evaluations.

Sandbox Gotcha

Do not elevate `shell_exec` to true in the SKILL.md frontmatter; hierarchical decomposition plans must remain purely analytical prior to the execution phase to prevent premature destructive commands.

3

Intent Matching & Trigger Invocation

Verify deterministic activation using tested natural language prompts and review the generated DAG plan.

Trigger the skill explicitly using frontmatter-aligned phrases. The agent will output a step-by-step DAG checklist with strict completion gates prior to issuing file modifications or executing bash commands.

PLAN.md
### Hierarchical Execution Plan (DAG)
- [ ] 1. Define PostgreSQL schema migration for tenant-scoped billing tables
- [ ] 2. Generate Prisma/Drizzle schema definitions and validate TypeScript types
- [ ] 3. Implement Stripe webhook handler verifying signature and idempotent events
- [ ] 4. Wire webhook handler into Express router with middleware validation
- [ ] 5. Write end-to-end integration tests using Vitest
- [ ] 6. Execute full verification suite (lint, typecheck, tests)
Production Pro-Tip

Instruct the agent to write its intermediate plan into a temporary `PLAN.md` file in the workspace root. This preserves context across context-window compactions.

Sandbox Gotcha

If the agent attempts to modify application files before writing the plan, reject the output and re-assert the trigger phrase.

4

Verification, Linting & Output Quality Gate

Enforce automated self-healing checks and plan reconciliation before accepting deliverables.

Once all subtasks are sequentially marked complete, the skill instructs the agent to run project linters, compiler checks, and unit tests. If any step fails, the agent must revise the remaining DAG rather than hallucinating ad-hoc fixes.

Terminal Command
npm run typecheck && npm run test -- --bail
scripts/verify-plan.sh
#!/usr/bin/env bash
set -euo pipefail

echo "Validating plan completion..."
git diff --exit-code PLAN.md || echo "PLAN.md updated."

echo "Running lint and typecheck..."
pnpm lint
pnpm typecheck

echo "Running isolated test suite..."
pnpm test --run
Production Pro-Tip

Review `git diff PLAN.md` alongside code changes during PR review to verify the agent did not skip prerequisite subtasks.

Sandbox Gotcha

Watch out for circular dependency loops where the agent continuously replans subtask 2 after subtask 4 fails; set a max retry limit of 3 replanning cycles in your instructions.

Real-World Scenario: Multi-Tenant Stripe Billing Webhook Integration & Ledger Sync

Tested Trigger Prompt (Feed directly into Codex, Claude, or Cursor):

“decompose large task: Implement multi-tenant Stripe subscription webhooks in our Fastify/Prisma backend. Ensure idempotent invoice processing, ledger balance reconciliation, and integration tests with mocked webhook events.”

Deterministic Agent Verification Pipeline:
Agent acknowledges the trigger 'decompose large task' and outputs a 6-step DAG plan to `PLAN.md` before touching any source files.
Agent executes Step 1 (Schema update for `Invoice` and `SubscriptionLedger` models) and verifies database types via `prisma generate`.
Agent executes Step 2 (Idempotency service using Redis transaction keys) and verifies with unit tests.
Agent encounters a TypeScript error in the Fastify raw body parser hook, pauses code generation, updates the plan to include raw payload buffering, resolves the issue, and marks the task complete.
Agent completes all remaining test suites and produces a final status summary with 0 failures.

Runtime Troubleshooting & Failure Modes

Error: Agent begins writing code immediately without generating a DAG plan: 'Writing src/billing/webhook.ts...'

Root Cause: The agent runtime did not load the SKILL.md manifest, or the user prompt did not match the registered triggers in the frontmatter.

Resolution Command / Fix:
Ensure prompt begins with an exact trigger phrase: 'create execution plan: <goal>' and confirm `.agents/skills/plan-and-solve-decomposition/SKILL.md` exists in the root.
Error: Replanning loop error: 'Subtask 3 failed. Generating revised plan... Subtask 3 failed. Generating revised plan...'

Root Cause: The agent is encountering a persistent environmental or permission failure (e.g., missing Docker daemon for integration test database) and repeatedly rewriting the DAG instead of failing fast.

Resolution Command / Fix:
Run `docker compose up -d postgres redis` to provide required local services, or add '--skip-integration-tests' to the subtask constraints.

Frequently Asked Questions (Plan-and-Solve Hierarchical Task Decomposition SOP)

Q:Can I use Plan-and-Solve Hierarchical Task Decomposition across Codex, Claude Code, and Cursor simultaneously?

Yes. The skill conforms to the universal SKILL.md specification. By placing the file in `.agents/skills/plan-and-solve-decomposition/SKILL.md` or linking it in `.cursorrules` and `.claude/skills.json`, all four runtimes parse and honor the identical DAG decomposition rules.

Q:How does Plan-and-Solve Hierarchical Task Decomposition prevent context window overflow during long agent sessions?

Instead of keeping the entire debugging history in the LLM context, the skill offloads state tracking to a structured checklist (such as `PLAN.md`). Subtasks are executed sequentially, allowing earlier subtask intermediate logs to be trimmed or summarized safely.

Q:Does this skill require escalated root or container permissions?

No. The skill is audited with a security score of 98/100. It requires read and workspace-write access to create planning and code files, while shell execution and external network calls remain restricted unless explicitly permitted by your IDE workspace policy.

Ready to equip your autonomous agent with Plan-and-Solve Hierarchical Task Decomposition?

Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.

Get 1-Click Install Spec