A deterministic, context-efficient system for implementing large PRDs with AI agents.
This skill enables your AI agent (Codex, OpenClaw, or any similar tool) to implement large Product Requirements Documents (PRDs) by breaking them into discrete tasks and executing each one in isolation with a fresh context. Instead of one long, context-bloated agent session, you get a structured loop where:
- A PRD is parsed into actionable tasks with dependencies
- Each task runs independently with clean context
- Every task is verified before marking complete
- Each success is committed to git with proper isolation
- The loop resumes automatically after interruptions or errors
When you give an AI agent a 50-page PRD and ask it to "build this," several things go wrong:
- Context window fills up with implementation details, losing sight of the big picture
- Agent forgets earlier decisions as conversation grows
- Errors compound because there's no verification gate between steps
- No checkpoints — if it crashes at step 45, you lose everything
- Difficult to resume or parallelize work
- Vibe-driven execution rather than systematic progress
✅ Context Reset Per Task — Every task starts fresh, focused only on its specific goal
✅ Deterministic Progress — TaskMaster manages dependencies and execution order
✅ Built-in Verification — Each task must pass npm run verify (tests + lint) before completion
✅ Atomic Commits — One commit per successful task, easy to review and rollback
✅ Graceful Resume — Stop and restart anytime without losing progress
✅ Unattended Operation — Watchdog keeps the loop alive, restarts on failures
✅ No Context Bloat — Codex sees only: task description + current codebase state
✅ Works with Any Agent — Codex CLI, OpenClaw, or any system that can run shell commands
┌─────────────────────────────────────────────────────────────────┐
│ 1. PRD (Product Requirements Document) │
│ - Single markdown file or multiple plan files │
└────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 2. TaskMaster Bootstrapping │
│ - Parse PRD → Initial task list │
│ - Analyze complexity │
│ - Expand into subtasks │
│ - Validate & fix dependencies │
│ - Generate task files (.taskmaster/tasks/*.md) │
└────────────────────┬────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 3. Task Execution Loop (task-loop.sh) │
│ │
│ ┌───────────────────────────────────────────┐ │
│ │ Select Next Available Task (dep-free) │ │
│ └───────┬───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────┐ │
│ │ Run Codex with Task File as Prompt │ │
│ │ (Fresh context: task + current code) │ │
│ └───────┬───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────┐ │
│ │ Verify Implementation │ │
│ │ (npm run verify: tests + lint) │ │
│ └───────┬───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────┐ │
│ │ Mark Task Complete │ │
│ └───────┬───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────┐ │
│ │ Git Commit (task(<id>): complete) │ │
│ └───────┬───────────────────────────────────┘ │
│ │ │
│ └───────► Repeat until all tasks done │
│ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ 4. Watchdog (Optional, for Unattended Runs) │
│ - Monitors task-loop.sh process │
│ - Auto-restarts if loop exits with remaining tasks │
│ - Graceful shutdown on completion or stop signal │
└─────────────────────────────────────────────────────────────────┘
| Script | Purpose |
|---|---|
compile-plan-prd.sh |
Merge multiple plan markdown files into a single PRD |
bootstrap-taskmaster.sh |
Parse PRD → Generate task files with dependencies |
task-loop.sh |
Execute tasks one-by-one with verification and commits |
task-loop-watchdog.sh |
Keep task-loop running unattended with auto-restart |
install-to-repo.sh |
Copy these scripts into a target repository |
Ensure these are installed:
- TaskMaster CLI — Task orchestration and dependency management
- Codex CLI — AI agent executor (or your preferred agent)
- Git — Version control for commits
- Node.js + npm/pnpm — For running verify scripts
- jq — JSON parsing in shell scripts
- Clone or reference this skill:
git clone <this-skill-repo> ~/.agents/skills/taskmaster-codex-loop- Install scripts into your target repo:
cd ~/my-project
~/.agents/skills/taskmaster-codex-loop/scripts/install-to-repo.sh .This copies the scripts to ~/my-project/scripts/.
- Configure TaskMaster for your repo:
Ensure .taskmaster/config.json exists with your AI provider settings:
{
"provider": "openai",
"model": "gpt-5.3-codex",
"apiKey": "your-api-key-or-env-var"
}- Set up verification command:
Add to package.json:
{
"scripts": {
"validate": "npm run lint && npm run test && npm run build",
"verify": "npm run validate",
"test": "vitest run",
"lint": "eslint ."
}
}Option A: Single PRD file
Create .taskmaster/docs/prd.md with your requirements.
Option B: Multiple plan files
Store plan files in implementation-plan/:
implementation-plan/
01-architecture.md
02-database.md
03-api.md
04-frontend.md
Then compile them:
./scripts/compile-plan-prd.sh implementation-plan .taskmaster/docs/prd.md./scripts/bootstrap-taskmaster.sh \
--input .taskmaster/docs/prd.md \
--tag mvp \
--num-tasks 35bootstrap-taskmaster.sh enables TaskMaster research mode by default.
Use default research mode for:
- first parse of a new PRD
- large/ambiguous scopes
- architecture-heavy or domain-unknown projects
Disable research for small incremental task refreshes:
./scripts/bootstrap-taskmaster.sh \
--input .taskmaster/docs/prd.md \
--tag mvp \
--num-tasks 12 \
--no-researchThis creates task files in .taskmaster/tasks/.
What happens:
- Parses PRD into ~35 initial tasks
- Analyzes complexity
- Expands complex tasks into subtasks
- Validates and fixes dependency ordering
- Generates markdown files for each task
Execute one task (manual mode):
./scripts/task-loop.shContinuous auto mode (runs until all tasks complete):
./scripts/task-loop.sh --autoContinuous mode with verify stall guards (recommended):
./scripts/task-loop.sh --auto --verify-idle-timeout 300 --verify-timeout 5400Stop at a checkpoint (e.g., after task 8 for review):
./scripts/task-loop.sh --auto --stop-after-task 8Full system access (for package installs):
./scripts/task-loop.sh --auto --codex-danger-full-accessGraceful stop:
./scripts/task-loop.sh --request-stopFor long-running projects, use the watchdog to keep the loop alive:
Foreground watchdog:
./scripts/task-loop-watchdog.sh --interval 300 --loop-arg "--verify-idle-timeout" --loop-arg "300"Background watchdog (unattended):
nohup ./scripts/task-loop-watchdog.sh --interval 300 \
--loop-arg "--verify-idle-timeout" --loop-arg "300" \
--loop-arg "--verify-timeout" --loop-arg "5400" \
> .taskmaster/task-loop-watchdog.out 2>&1 &Stop the watchdog:
./scripts/task-loop-watchdog.sh --request-stopWhen using this skill with your agent, follow these practices:
Don't treat the loop as "fire and forget." Your agent should periodically check:
# Check running processes
pgrep -af "task-loop.sh|task-loop-watchdog.sh|codex exec"
# Check current task state
cat .taskmaster/task-loop-state.json
# State-file age (seconds)
now="$(date +%s)"; mtime="$(stat -f %m .taskmaster/task-loop-state.json 2>/dev/null || stat -c %Y .taskmaster/task-loop-state.json 2>/dev/null || echo 0)"; echo $((now-mtime))
# View recent watchdog logs
tail -n 120 .taskmaster/task-loop-watchdog.out
# Verify/test process tree (stuck detection)
pgrep -af "npm run verify|turbo run test|tsx --test"
# Check overall progress
task-master list --format json | jq '{
done: (.tasks | map(select(.status=="done")) | length),
in_progress: [.tasks[] | select(.status=="in-progress") | .id],
pending: (.tasks | map(select(.status=="pending")) | length)
}'
# Verify code is actually changing
git status --short
git log --oneline -10- Verify phase stuck/no output for >5 minutes — Restart with
--verify-idle-timeout 300 - Task stuck for >10 minutes — Check logs, may need manual fix
- Verify fails repeatedly — Review the task requirements or fix test issues
- Dependency install failures — May need
--codex-danger-full-access - Context confusion — Task description may need refinement in TaskMaster
After each completed task, report:
- ✅ Task ID and title
- 📝 Commit hash
- ✔️ Verify result (passed/failed)
- 🚧 Any blockers or issues
| Option | Description | Default |
|---|---|---|
--model |
Codex model to use | gpt-5.3-codex |
--verify-cmd |
Verification command | npm run verify |
--verify-timeout <sec> |
Max total verify runtime before fail | 1800 |
--verify-idle-timeout <sec> |
Max seconds with no verify output before fail | 300 |
--codex-sandbox |
Sandbox mode: read-only, workspace-write, danger-full-access |
workspace-write |
--auto |
Run continuously until all tasks complete | Off |
--stop-after-task <id> |
Stop after completing specific task | None |
--allow-dirty |
Allow running with uncommitted changes | Off |
--no-resume |
Ignore existing resume state | Off |
| Option | Description | Default |
|---|---|---|
--interval |
Seconds between health checks | 30 |
--max-restarts |
Max restart attempts (0=unlimited) | 0 |
--loop-arg |
Pass args to task-loop.sh | None |
Symptom: Codex can't install packages during task execution
Solution: Use full-access mode:
./scripts/task-loop.sh --auto --codex-danger-full-accessOr pre-install dependencies:
pnpm installSymptom: task-loop.sh stops running, but tasks remain
Solution: Use the watchdog instead:
./scripts/task-loop-watchdog.sh --interval 300 --loop-arg "--verify-idle-timeout" --loop-arg "300"Symptom: Loop blocks because npm run verify fails
Solutions:
- Fix test/lint issues manually
- Adjust verify command:
--verify-cmd "npm run test" - Review task quality — may need better task descriptions
Symptom: "Working tree is dirty" error
Solutions:
- Commit or stash changes
- Use
--allow-dirty(for active dev branches only)
Symptom: Task 24 runs before Task 20
Explanation: TaskMaster uses dependency graphs, not numeric order. This is intentional.
Solution: Use --stop-after-task for manual checkpoints if needed.
Symptom: Codex can't find installed packages
Solution: Ensure hoisting is configured, or use danger-full-access mode.
TaskMaster-generated tasks should be:
- Specific — "Implement user authentication API endpoint" not "Add auth"
- Testable — Include acceptance criteria
- Independent — Minimize dependencies when possible
Your npm run verify command should:
- Call
npm run validate - Run unit tests
- Run integration tests (if fast)
- Lint code
- Type-check (TypeScript)
- Exit with non-zero on any failure
For critical milestones, stop the loop to manually review:
./scripts/task-loop.sh --auto --stop-after-task 12
# Review changes, test manually
git push
./scripts/task-loop.sh --auto --stop-after-task 24The loop uses: task(<id>): complete
This makes it easy to trace commits back to task files:
git log --grep="task(8)"Don't run multiple task-loops simultaneously in the same repo. This causes:
- Duplicate verify runs
- Git conflicts
- State file corruption
When running watchdog in background:
# Start
nohup ./scripts/task-loop-watchdog.sh --interval 300 \
--loop-arg "--verify-idle-timeout" --loop-arg "300" \
--loop-arg "--verify-timeout" --loop-arg "5400" \
> .taskmaster/watchdog.log 2>&1 &
echo $! > .taskmaster/watchdog.pid
# Monitor
tail -f .taskmaster/watchdog.log
# Stop gracefully
./scripts/task-loop-watchdog.sh --request-stop
rm .taskmaster/watchdog.pidThis skill is built for Codex CLI:
./scripts/task-loop.sh --model gpt-5.3-codexShould work with OpenClaw if it exposes a similar CLI:
# Modify task-loop.sh to call OpenClaw instead:
# openclaw exec --prompt "$TASK_FILE" --sandbox workspace-writeAny agent that can:
- Read a markdown file (task description)
- Make code changes
- Be invoked from shell
- Exit with success/failure status
Can replace Codex in task-loop.sh.
After setup, your repo will have:
your-repo/
├── .taskmaster/
│ ├── config.json # TaskMaster + AI config
│ ├── docs/
│ │ └── prd.md # Compiled PRD
│ ├── tasks/
│ │ ├── tasks.json # Task metadata
│ │ ├── task-1.md # Individual task files
│ │ ├── task-2.md
│ │ └── ...
│ ├── task-loop-state.json # Resume state
│ └── task-loop-watchdog.out # Watchdog logs
├── scripts/
│ ├── bootstrap-taskmaster.sh # PRD → Tasks
│ ├── compile-plan-prd.sh # Merge plans
│ ├── task-loop.sh # Main executor
│ ├── task-loop-watchdog.sh # Auto-restart monitor
│ └── install-to-repo.sh # Setup helper
└── implementation-plan/ # Optional: multi-file PRDs
├── 01-architecture.md
└── 02-database.md
This skill is designed for use with TaskMaster and Codex CLI as part of agent-driven development workflows.
Created for: Deterministic, context-efficient PRD implementation
Works with: Codex (OpenAI), OpenClaw, or any shell-invocable AI agent
Dependencies: TaskMaster, Git, Node.js, jq
# 1. Install scripts to your repo
cd ~/my-project
~/.agents/skills/taskmaster-codex-loop/scripts/install-to-repo.sh .
# 2. Create PRD
mkdir -p .taskmaster/docs
cat > .taskmaster/docs/prd.md << 'EOF'
# My Project PRD
Build a REST API for managing todo items with:
- CRUD operations
- User authentication
- PostgreSQL database
- Express.js backend
- Input validation
- Unit tests
EOF
# 3. Bootstrap tasks
./scripts/bootstrap-taskmaster.sh --input .taskmaster/docs/prd.md --num-tasks 20
# 4. Run the loop
./scripts/task-loop.sh --auto
# 5. Monitor progress
watch -n 5 'task-master list --with-subtasks'Now your agent will systematically implement the PRD, one verified task at a time, with clean context per task.
No more lost context. No more runaway sessions. Just deterministic progress. 🚀