and-or-planner
Skill2 starsChanged 6 months agoMITView on GitHub
Autonomous AND/OR task planner. Invoke BEFORE executing any task that meets: (Check 1: has multiple required subtasks that ALL must succeed — conjunctive requirements) OR (Check 2: has multiple valid approaches where one might fail — alternatives), AND (Check 3: involves 3+ discrete steps OR any external dependency such as a package, service, or API). Do NOT invoke for simple linear tasks — Check 3 alone is not sufficient. Examples that should trigger: setting up a database + running migrations + seeding (Check 1 + Check 3); installing lodash with underscore as fallback — even just 2 steps (Check 2 + external dep clause of Check 3); configuring multiple CI steps that all must pass.
- Installs packages
In this repository13 other files it gives its agents.
- beyond-obviousSkill
- beyond-the-summarySkill
- farnsworth-rhetoricSkill
- great-demoSkill
- humanizerSkill
- human-narrativeSkill
- intelligence-flow-architectureSkill
- markdown-fetchSkill
- skill-builderSkill
- source-checkSkill
- split-pdfSkill
- start-with-whySkill
- strategic-persuasion-writingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 9 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Run this self-assessment before generating the tree:
- Distinctive: line 39
If the trigger condition is not met, stop here — execute the task normally without a tree.
- Distinctive: line 51
Every node must have a type and status.
- Very specific: line 57
Check if .and-or-plan.md already exists:
- Distinctive: line 61
Write the file at the project root:
- Distinctive: line 83
Update node statuses in this file throughout execution.
- Very specific: line 85
If a .gitignore exists, suggest adding:
- Distinctive: line 110
Stop — do not attempt remaining OR children from a dirty state.
- Very specific: line 115
If all OR children fail: mark OR node FAILED, propagate up.
- Very specific: line 129
Leave .and-or-plan.md in place
- Distinctive: line 155
Check 1: Yes — install + middleware + tests must ALL succeed
- Distinctive: line 156
Check 2: Yes — jsonwebtoken or jose are both valid
- Distinctive: line 157
Check 3: Yes — 3+ steps, external package dependency
- Very specific: line 191
Update Status: completed, move file to .claude/and-or-history/
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AND/OR Planner
Announce at start: "Using and-or-planner to structure this task before execution."
What This Does
Before executing a complex task, this skill generates an AND/OR tree that makes the task's structure explicit: AND nodes enforce that all required subtasks complete; OR nodes pre-rank alternative approaches and try them in order on failure. The tree is written to .and-or-plan.md and updated live during execution.
This addresses two failure modes:
- Premature abandonment — giving up when the first approach fails instead of trying alternatives
- Incomplete completion — stopping when some required subtasks succeed instead of all of them
Step 1: Trigger Check
Run this self-assessment before generating the tree:
- Conjunctive check — does this task require multiple distinct things that ALL must succeed?
- Alternative check — does this task have multiple valid approaches where one might fail?
- Complexity floor — does the task involve 3+ discrete steps OR any external dependency (package, service, API)?
Fire if: (Check 1 OR Check 2) AND Check 3.
If the trigger condition is not met, stop here — execute the task normally without a tree.
Step 2: Generate the Tree
Analyze the task and produce an AND/OR tree. Apply these rules before writing:
Generation rules:
- Root is always an AND node (the overall goal requires all subtasks)
- OR nodes represent points where multiple approaches exist — score each child 0.0–1.0 by estimated likelihood of success in this codebase context. Highest score = tried first.
- OR nodes must have ≥2 children. If you produce a single-child OR, collapse it — replace the OR node with its child directly.
- AND nodes represent groups where all children must complete.
- ACTION nodes are atomic leaf operations: a single command, file write, or verifiable step.
- Every node must have a type and status. Every OR child must have a score.
On generation failure (malformed tree, file write error): warn — ⚠ AND/OR tree generation failed: [reason]. Falling back to linear execution. — and proceed without a tree.
Step 3: Write .and-or-plan.md
Check if .and-or-plan.md already exists:
Status: in_progress→ context reset; skip to Step 5 (Resume)Status: completedorStatus: failed→ archive it first: move to.claude/and-or-history/YYYY-MM-DD-[slug].md(create dir if needed), then overwrite
Write the file at the project root:
# AND/OR Plan: [task description]
Generated: [ISO 8601 timestamp]
Status: in_progress
## Tree
- AND: [root goal] [PENDING]
- OR: [sub-goal] [PENDING]
- ACTION: [approach 1] (score: 0.9) [PENDING]
- ACTION: [approach 2] (score: 0.6) [PENDING]
- AND: [required group] [PENDING]
- ACTION: [step 1] [PENDING]
- ACTION: [step 2] [PENDING]Node statuses: PENDING → IN_PROGRESS → SUCCESS | FAILED | PRUNED
PRUNED is applied to OR siblings that are never attempted because an earlier sibling succeeded. Do not leave them as PENDING — mark them PRUNED when the OR node resolves to SUCCESS.
Update node statuses in this file throughout execution. The file reflects live state — it's resumable and user-editable.
If a .gitignore exists, suggest adding:
.and-or-plan.md
.claude/and-or-history/Step 4: Execute the Tree (DFS)
Traverse depth-first. Update node status to IN_PROGRESS when entering, then SUCCESS or FAILED on completion.
AND nodes
Execute all children sequentially. Mark SUCCESS when all children are SUCCESS. If any child reaches FAILED, mark the AND node FAILED immediately — do not continue remaining children. Propagate failure up to the parent.
OR nodes
Execute children in descending score order. Mark SUCCESS as soon as any child succeeds — do not execute remaining children.
On child failure:
- Announce (non-blocking, no confirmation needed):
⟳ Approach failed: [child name] — [brief reason] Trying next: [next child name] (score: [score]) - Rollback side effects from the failed child (uninstall packages, revert created files)
- If rollback fails: mark the OR node
FAILED, surface to user:⚠ Rollback failed for [approach]: [reason]. Cannot safely attempt next branch.Stop — do not attempt remaining OR children from a dirty state.
- If rollback fails: mark the OR node
- Attempt next child
On child success: mark all remaining unexecuted OR siblings PRUNED, then mark the OR node SUCCESS. Do not leave untried siblings as PENDING.
If all OR children fail: mark OR node FAILED, propagate up.
ACTION nodes
Execute the atomic operation. Verify the outcome. Mark SUCCESS or FAILED.
Step 5: File Lifecycle
On success (root AND reaches SUCCESS)
- Update file:
Status: completed - Move
.and-or-plan.md→.claude/and-or-history/YYYY-MM-DD-[task-slug].md(create.claude/and-or-history/if it doesn't exist)
On failure (all branches exhausted, root FAILED)
- Update file:
Status: failed - Leave
.and-or-plan.mdin place - Surface summary to user:
✗ AND/OR plan failed. Tried: - [branch 1]: [failure reason] - [branch 2]: [failure reason] Blocked on: [specific node and reason] To resume after editing: change `Status: failed` to `Status: in_progress` in .and-or-plan.md — Claude will detect it on next context start.
On context reset (Step 5, Resume)
.and-or-plan.md exists with Status: in_progress at session start:
- Announce:
Found in-progress AND/OR plan — resuming from [node name] - Traverse from the last
IN_PROGRESSnode, or the firstPENDINGnode if no IN_PROGRESS nodes exist - Within AND nodes: skip children already in
SUCCESSstate — do not re-run succeeded work - Continue DFS normally from the resume point
Reference Example
Task: "Set up authentication — install JWT library, create middleware, add tests"
Trigger check:
- Check 1: Yes — install + middleware + tests must ALL succeed
- Check 2: Yes — jsonwebtoken or jose are both valid
- Check 3: Yes — 3+ steps, external package dependency
- Result: FIRE
Generated tree:
# AND/OR Plan: Set up authentication
Generated: 2026-03-11T15:00:00Z
Status: in_progress
## Tree
- AND: Set up authentication [IN_PROGRESS]
- OR: JWT library [PENDING]
- ACTION: npm install jsonwebtoken (score: 0.9) [PENDING]
- ACTION: npm install jose (score: 0.6) [PENDING]
- AND: Middleware [PENDING]
- ACTION: Create src/middleware/auth.ts [PENDING]
- ACTION: Register middleware in src/app.ts [PENDING]
- AND: Tests [PENDING]
- ACTION: Write unit tests for token generation [PENDING]
- ACTION: Write integration tests for protected routes [PENDING]Execution trace:
- Enter root AND → IN_PROGRESS
- Enter OR (JWT library) → IN_PROGRESS
- Attempt
npm install jsonwebtoken→ fails (peer dep conflict) - Announce:
⟳ Approach failed: npm install jsonwebtoken — peer dependency conflict with Node 22. Trying next: npm install jose (score: 0.6) - Rollback:
npm uninstall jsonwebtoken→ succeeds - Attempt
npm install jose→ SUCCESS - OR node → SUCCESS
- Enter AND (Middleware) → execute Create auth.ts → SUCCESS → Register middleware → SUCCESS → AND SUCCESS
- Enter AND (Tests) → execute unit tests → SUCCESS → integration tests → SUCCESS → AND SUCCESS
- Root AND → SUCCESS
- Update Status: completed, move file to .claude/and-or-history/
Note: this trace exercises the failure-then-success OR path (first child fails, second succeeds) — both children are attempted, so no PRUNED siblings are produced in this trace. The PRUNED-on-first-success scenario (first child succeeds, remaining siblings marked PRUNED) is covered by the "Correct PRUNED status" scenario in ~/.claude/skills/and-or-planner/VERIFICATION-SCENARIOS.md, which is the authoritative reference for that behavior.
For all failure-path traces (OR exhaustion, rollback failure, multi-level AND propagation), also treat VERIFICATION-SCENARIOS.md as the authoritative reference.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

