From 7f891418fe02bb6919cc491f8d358518c3ad6b8c Mon Sep 17 00:00:00 2001 From: Aaron Goldsmith Date: Sat, 21 Mar 2026 09:26:32 -0700 Subject: [PATCH 1/3] Add /tree-solve skill for recursive task decomposition Launches a tree of agents that decompose complex tasks into subtasks, delegate to child processes, and aggregate results. Each level can execute directly or decompose further via claude --agent tree-solver. Co-Authored-By: Claude Opus 4.6 --- .claude/skills/tree-solve/SKILL.md | 158 +++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 .claude/skills/tree-solve/SKILL.md diff --git a/.claude/skills/tree-solve/SKILL.md b/.claude/skills/tree-solve/SKILL.md new file mode 100644 index 0000000..2ab4a78 --- /dev/null +++ b/.claude/skills/tree-solve/SKILL.md @@ -0,0 +1,158 @@ +commit fe66e75cc7f79b4ed77b2c8490f4e19862924bad +Author: Aaron Goldsmith +Date: Sat Mar 21 09:13:05 2026 -0700 + + Add agentic competition tasks, agent definitions, and skills + + - Agent definitions: competition-tasks, depth-test, tree-solver + - Skills: mobius-evolve (free Opus evolution), tree-solve (recursive decomposition) + - Competition tasks: standard + agentic (tool-heavy, multi-tier) + - Cleanup script for dead-weight agents + - Fix hardcoded paths in agentic tasks to use relative paths + - Make system monitoring task cross-platform (Unix tools) + - Remove unused import in cleanup_agents.py + - Add .tree-workspace/ to .gitignore + + Co-Authored-By: Claude Opus 4.6 + +diff --git a/.claude/skills/tree-solve/SKILL.md b/.claude/skills/tree-solve/SKILL.md +new file mode 100644 +index 0000000..1082d58 +--- /dev/null ++++ b/.claude/skills/tree-solve/SKILL.md +@@ -0,0 +1,135 @@ ++--- ++name: tree-solve ++description: Recursive task decomposition using a tree of agents. Use when the user says "tree solve", "decompose this", "break this down", or has a complex multi-part task that benefits from hierarchical delegation. ++user-invocable: true ++argument-hint: [--depth N] [--model MODEL] ++--- ++ ++# Tree Solver — Recursive Task Decomposition ++ ++You are launching a **tree-solver** session: a recursive agent system that decomposes complex tasks into subtasks, delegates each to child agents, and aggregates results back up the tree. ++ ++## How it works ++ ++``` ++You (main thread, orchestrator) ++ ├── spawns Agent A (subtask 1) ──→ may spawn its own child processes ++ ├── spawns Agent B (subtask 2) ──→ may spawn its own child processes ++ └── aggregates all results into final output ++``` ++ ++Each level can either **execute directly** (leaf node) or **decompose further** by launching `claude --agent tree-solver` as a background process, creating true recursion. ++ ++## Parse arguments ++ ++- **Task**: The main argument (required) ++- **--depth N**: Max recursion depth (default: 2). Higher = more decomposition. Recommend 2-3. ++- **--model MODEL**: Model for child solvers (default: sonnet). Use `haiku` for cheaper runs. ++ ++## Step 1: Set up workspace ++ ++```bash ++SESSION_ID="tree-$(date +%Y%m%d-%H%M%S)" ++WORKSPACE="$(pwd)/.tree/${SESSION_ID}" ++mkdir -p "${WORKSPACE}/root" ++``` ++ ++Tell the user the session ID and workspace path. ++ ++## Step 2: Analyze the task ++ ++Before decomposing, think about the task: ++- What are the **natural seams** where this splits into independent work? ++- Is decomposition actually valuable here, or should you just do it directly? ++- What's the right granularity? (2-4 subtasks per level is ideal) ++ ++If the task is simple enough to do directly, skip decomposition — just do it and write the result. ++ ++## Step 3: Decompose (if warranted) ++ ++Write a decomposition plan to `{WORKSPACE}/root/plan.md`: ++- List each subtask with a clear, self-contained description ++- Note dependencies between subtasks (if any) ++- Describe how results will be aggregated ++ ++## Step 4: Spawn child solvers ++ ++For each subtask, create the child's task file and launch it. ++ ++**For independent subtasks — launch in parallel:** ++ ++```bash ++mkdir -p "{WORKSPACE}/root-1" ++# Write the task file ++cat > "{WORKSPACE}/root-1/task.md" << 'EOF' ++TREE_TASK: {detailed subtask description with full context} ++TREE_NODE: root-1 ++TREE_DEPTH: 1 ++TREE_MAX_DEPTH: {max_depth} ++TREE_WORKSPACE: {WORKSPACE} ++TREE_CONTEXT: {what the parent task is, how this subtask fits in} ++EOF ++``` ++ ++Then spawn the child solver process: ++ ++```bash ++claude -p "$(cat {WORKSPACE}/root-1/task.md)" --agent tree-solver --model {MODEL} --max-turns 30 > "{WORKSPACE}/root-1/output.log" 2>&1 & ++``` ++ ++**IMPORTANT**: Launch independent children in the background with `&` and use `wait` to collect them all. ++ ++For subtasks with dependencies, launch sequentially. ++ ++## Step 5: Monitor and collect ++ ++```bash ++wait # Wait for all background children to complete ++``` ++ ++Then check each child's results: ++```bash ++for child_dir in {WORKSPACE}/root-*/; do ++ echo "=== $(basename $child_dir) ===" ++ if [ -f "$child_dir/result.md" ]; then ++ cat "$child_dir/result.md" ++ else ++ echo "NO RESULT — check $child_dir/output.log" ++ fi ++done ++``` ++ ++## Step 6: Aggregate ++ ++Read all child results and synthesize them into a coherent final output. Write to `{WORKSPACE}/root/result.md`. ++ ++Consider: ++- Did all children succeed? Handle partial failures gracefully. ++- Do the pieces fit together? Resolve any conflicts or gaps. ++- Is the combined result better than what a single agent would have produced? ++ ++## Step 7: Present to user ++ ++Show: ++1. **The tree structure** — which nodes decomposed, which executed ++2. **The final result** — the aggregated output ++3. **Stats** — how many agents were involved, depth reached, any failures ++ ++```bash ++echo "=== Tree Structure ===" ++find {WORKSPACE} -name "*.md" | sort ++echo "" ++echo "=== Final Result ===" ++cat {WORKSPACE}/root/result.md ++``` ++ ++## Guidelines ++ ++- **Depth 1** is great for most tasks (split into 2-4 pieces, execute each) ++- **Depth 2** for genuinely complex tasks (architecture + implementation + testing) ++- **Depth 3** rarely needed — only for massive scope ++- **Context is everything**: Each child must have enough context to work independently. Over-communicate in task descriptions. ++- **Don't decompose for the sake of it**: If a subtask at any level is atomic, just execute it. ++- **Workspace discipline**: All files go in the workspace. This makes it easy to inspect, debug, and clean up. ++- **Never delete `.tree/` wholesale** — other sessions may be active. Only clean up your own session: `rm -rf .tree/{SESSION_ID}/`. Always confirm the session ID before deleting. ++- Before cleanup, check if other sessions exist: `ls .tree/` — if there are directories besides yours, leave them alone. From 312fcb2898de01dd67f5f14cd525934ce49489f9 Mon Sep 17 00:00:00 2001 From: Aaron Goldsmith Date: Sat, 21 Mar 2026 10:07:06 -0700 Subject: [PATCH 2/3] Fix broken SKILL.md (strip git metadata), fix shell variable quoting Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/skills/tree-solve/SKILL.md | 293 +++++++++++++---------------- 1 file changed, 135 insertions(+), 158 deletions(-) diff --git a/.claude/skills/tree-solve/SKILL.md b/.claude/skills/tree-solve/SKILL.md index 2ab4a78..fd3b3fa 100644 --- a/.claude/skills/tree-solve/SKILL.md +++ b/.claude/skills/tree-solve/SKILL.md @@ -1,158 +1,135 @@ -commit fe66e75cc7f79b4ed77b2c8490f4e19862924bad -Author: Aaron Goldsmith -Date: Sat Mar 21 09:13:05 2026 -0700 - - Add agentic competition tasks, agent definitions, and skills - - - Agent definitions: competition-tasks, depth-test, tree-solver - - Skills: mobius-evolve (free Opus evolution), tree-solve (recursive decomposition) - - Competition tasks: standard + agentic (tool-heavy, multi-tier) - - Cleanup script for dead-weight agents - - Fix hardcoded paths in agentic tasks to use relative paths - - Make system monitoring task cross-platform (Unix tools) - - Remove unused import in cleanup_agents.py - - Add .tree-workspace/ to .gitignore - - Co-Authored-By: Claude Opus 4.6 - -diff --git a/.claude/skills/tree-solve/SKILL.md b/.claude/skills/tree-solve/SKILL.md -new file mode 100644 -index 0000000..1082d58 ---- /dev/null -+++ b/.claude/skills/tree-solve/SKILL.md -@@ -0,0 +1,135 @@ -+--- -+name: tree-solve -+description: Recursive task decomposition using a tree of agents. Use when the user says "tree solve", "decompose this", "break this down", or has a complex multi-part task that benefits from hierarchical delegation. -+user-invocable: true -+argument-hint: [--depth N] [--model MODEL] -+--- -+ -+# Tree Solver — Recursive Task Decomposition -+ -+You are launching a **tree-solver** session: a recursive agent system that decomposes complex tasks into subtasks, delegates each to child agents, and aggregates results back up the tree. -+ -+## How it works -+ -+``` -+You (main thread, orchestrator) -+ ├── spawns Agent A (subtask 1) ──→ may spawn its own child processes -+ ├── spawns Agent B (subtask 2) ──→ may spawn its own child processes -+ └── aggregates all results into final output -+``` -+ -+Each level can either **execute directly** (leaf node) or **decompose further** by launching `claude --agent tree-solver` as a background process, creating true recursion. -+ -+## Parse arguments -+ -+- **Task**: The main argument (required) -+- **--depth N**: Max recursion depth (default: 2). Higher = more decomposition. Recommend 2-3. -+- **--model MODEL**: Model for child solvers (default: sonnet). Use `haiku` for cheaper runs. -+ -+## Step 1: Set up workspace -+ -+```bash -+SESSION_ID="tree-$(date +%Y%m%d-%H%M%S)" -+WORKSPACE="$(pwd)/.tree/${SESSION_ID}" -+mkdir -p "${WORKSPACE}/root" -+``` -+ -+Tell the user the session ID and workspace path. -+ -+## Step 2: Analyze the task -+ -+Before decomposing, think about the task: -+- What are the **natural seams** where this splits into independent work? -+- Is decomposition actually valuable here, or should you just do it directly? -+- What's the right granularity? (2-4 subtasks per level is ideal) -+ -+If the task is simple enough to do directly, skip decomposition — just do it and write the result. -+ -+## Step 3: Decompose (if warranted) -+ -+Write a decomposition plan to `{WORKSPACE}/root/plan.md`: -+- List each subtask with a clear, self-contained description -+- Note dependencies between subtasks (if any) -+- Describe how results will be aggregated -+ -+## Step 4: Spawn child solvers -+ -+For each subtask, create the child's task file and launch it. -+ -+**For independent subtasks — launch in parallel:** -+ -+```bash -+mkdir -p "{WORKSPACE}/root-1" -+# Write the task file -+cat > "{WORKSPACE}/root-1/task.md" << 'EOF' -+TREE_TASK: {detailed subtask description with full context} -+TREE_NODE: root-1 -+TREE_DEPTH: 1 -+TREE_MAX_DEPTH: {max_depth} -+TREE_WORKSPACE: {WORKSPACE} -+TREE_CONTEXT: {what the parent task is, how this subtask fits in} -+EOF -+``` -+ -+Then spawn the child solver process: -+ -+```bash -+claude -p "$(cat {WORKSPACE}/root-1/task.md)" --agent tree-solver --model {MODEL} --max-turns 30 > "{WORKSPACE}/root-1/output.log" 2>&1 & -+``` -+ -+**IMPORTANT**: Launch independent children in the background with `&` and use `wait` to collect them all. -+ -+For subtasks with dependencies, launch sequentially. -+ -+## Step 5: Monitor and collect -+ -+```bash -+wait # Wait for all background children to complete -+``` -+ -+Then check each child's results: -+```bash -+for child_dir in {WORKSPACE}/root-*/; do -+ echo "=== $(basename $child_dir) ===" -+ if [ -f "$child_dir/result.md" ]; then -+ cat "$child_dir/result.md" -+ else -+ echo "NO RESULT — check $child_dir/output.log" -+ fi -+done -+``` -+ -+## Step 6: Aggregate -+ -+Read all child results and synthesize them into a coherent final output. Write to `{WORKSPACE}/root/result.md`. -+ -+Consider: -+- Did all children succeed? Handle partial failures gracefully. -+- Do the pieces fit together? Resolve any conflicts or gaps. -+- Is the combined result better than what a single agent would have produced? -+ -+## Step 7: Present to user -+ -+Show: -+1. **The tree structure** — which nodes decomposed, which executed -+2. **The final result** — the aggregated output -+3. **Stats** — how many agents were involved, depth reached, any failures -+ -+```bash -+echo "=== Tree Structure ===" -+find {WORKSPACE} -name "*.md" | sort -+echo "" -+echo "=== Final Result ===" -+cat {WORKSPACE}/root/result.md -+``` -+ -+## Guidelines -+ -+- **Depth 1** is great for most tasks (split into 2-4 pieces, execute each) -+- **Depth 2** for genuinely complex tasks (architecture + implementation + testing) -+- **Depth 3** rarely needed — only for massive scope -+- **Context is everything**: Each child must have enough context to work independently. Over-communicate in task descriptions. -+- **Don't decompose for the sake of it**: If a subtask at any level is atomic, just execute it. -+- **Workspace discipline**: All files go in the workspace. This makes it easy to inspect, debug, and clean up. -+- **Never delete `.tree/` wholesale** — other sessions may be active. Only clean up your own session: `rm -rf .tree/{SESSION_ID}/`. Always confirm the session ID before deleting. -+- Before cleanup, check if other sessions exist: `ls .tree/` — if there are directories besides yours, leave them alone. +--- +name: tree-solve +description: Recursive task decomposition using a tree of agents. Use when the user says "tree solve", "decompose this", "break this down", or has a complex multi-part task that benefits from hierarchical delegation. +user-invocable: true +argument-hint: [--depth N] [--model MODEL] +--- + +# Tree Solver — Recursive Task Decomposition + +You are launching a **tree-solver** session: a recursive agent system that decomposes complex tasks into subtasks, delegates each to child agents, and aggregates results back up the tree. + +## How it works + +``` +You (main thread, orchestrator) + ├── spawns Agent A (subtask 1) ──→ may spawn its own child processes + ├── spawns Agent B (subtask 2) ──→ may spawn its own child processes + └── aggregates all results into final output +``` + +Each level can either **execute directly** (leaf node) or **decompose further** by launching `claude --agent tree-solver` as a background process, creating true recursion. + +## Parse arguments + +- **Task**: The main argument (required) +- **--depth N**: Max recursion depth (default: 2). Higher = more decomposition. Recommend 2-3. +- **--model MODEL**: Model for child solvers (default: sonnet). Use `haiku` for cheaper runs. + +## Step 1: Set up workspace + +```bash +SESSION_ID="tree-$(date +%Y%m%d-%H%M%S)" +WORKSPACE="$(pwd)/.tree/${SESSION_ID}" +mkdir -p "${WORKSPACE}/root" +``` + +Tell the user the session ID and workspace path. + +## Step 2: Analyze the task + +Before decomposing, think about the task: +- What are the **natural seams** where this splits into independent work? +- Is decomposition actually valuable here, or should you just do it directly? +- What's the right granularity? (2-4 subtasks per level is ideal) + +If the task is simple enough to do directly, skip decomposition — just do it and write the result. + +## Step 3: Decompose (if warranted) + +Write a decomposition plan to `${WORKSPACE}/root/plan.md`: +- List each subtask with a clear, self-contained description +- Note dependencies between subtasks (if any) +- Describe how results will be aggregated + +## Step 4: Spawn child solvers + +For each subtask, create the child's task file and launch it. + +**For independent subtasks — launch in parallel:** + +```bash +mkdir -p "${WORKSPACE}/root-1" +# Write the task file +cat > "${WORKSPACE}/root-1/task.md" << 'EOF' +TREE_TASK: {detailed subtask description with full context} +TREE_NODE: root-1 +TREE_DEPTH: 1 +TREE_MAX_DEPTH: {max_depth} +TREE_WORKSPACE: ${WORKSPACE} +TREE_CONTEXT: {what the parent task is, how this subtask fits in} +EOF +``` + +Then spawn the child solver process: + +```bash +claude -p "$(cat "${WORKSPACE}/root-1/task.md")" --agent tree-solver --model "${MODEL}" --max-turns 30 > "${WORKSPACE}/root-1/output.log" 2>&1 & +``` + +**IMPORTANT**: Launch independent children in the background with `&` and use `wait` to collect them all. + +For subtasks with dependencies, launch sequentially. + +## Step 5: Monitor and collect + +```bash +wait # Wait for all background children to complete +``` + +Then check each child's results: +```bash +for child_dir in "${WORKSPACE}"/root-*/; do + echo "=== $(basename "$child_dir") ===" + if [ -f "$child_dir/result.md" ]; then + cat "$child_dir/result.md" + else + echo "NO RESULT — check $child_dir/output.log" + fi +done +``` + +## Step 6: Aggregate + +Read all child results and synthesize them into a coherent final output. Write to `${WORKSPACE}/root/result.md`. + +Consider: +- Did all children succeed? Handle partial failures gracefully. +- Do the pieces fit together? Resolve any conflicts or gaps. +- Is the combined result better than what a single agent would have produced? + +## Step 7: Present to user + +Show: +1. **The tree structure** — which nodes decomposed, which executed +2. **The final result** — the aggregated output +3. **Stats** — how many agents were involved, depth reached, any failures + +```bash +echo "=== Tree Structure ===" +find "${WORKSPACE}" -name "*.md" | sort +echo "" +echo "=== Final Result ===" +cat "${WORKSPACE}/root/result.md" +``` + +## Guidelines + +- **Depth 1** is great for most tasks (split into 2-4 pieces, execute each) +- **Depth 2** for genuinely complex tasks (architecture + implementation + testing) +- **Depth 3** rarely needed — only for massive scope +- **Context is everything**: Each child must have enough context to work independently. Over-communicate in task descriptions. +- **Don't decompose for the sake of it**: If a subtask at any level is atomic, just execute it. +- **Workspace discipline**: All files go in the workspace. This makes it easy to inspect, debug, and clean up. +- **Never delete `.tree/` wholesale** — other sessions may be active. Only clean up your own session: `rm -rf ".tree/${SESSION_ID}/"`. Always confirm the session ID before deleting. +- Before cleanup, check if other sessions exist: `ls .tree/` — if there are directories besides yours, leave them alone. From 77ff3ec064a1b2a28e6a9f5f6dd8701c6fbb1a13 Mon Sep 17 00:00:00 2001 From: Aaron Goldsmith Date: Sat, 21 Mar 2026 10:19:25 -0700 Subject: [PATCH 3/3] Fix tree-solve: reuse parent workspace, expand heredoc vars, correct skill invocation - Check TREE_WORKSPACE env var before creating fresh session (child node reuse) - Change heredoc from << 'EOF' to << EOF so shell variables expand - Replace --agent tree-solver with --append-system-prompt for /tree-solve skill - Pass TREE_WORKSPACE env var to child processes Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/skills/tree-solve/SKILL.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.claude/skills/tree-solve/SKILL.md b/.claude/skills/tree-solve/SKILL.md index fd3b3fa..d797152 100644 --- a/.claude/skills/tree-solve/SKILL.md +++ b/.claude/skills/tree-solve/SKILL.md @@ -29,8 +29,13 @@ Each level can either **execute directly** (leaf node) or **decompose further** ## Step 1: Set up workspace ```bash -SESSION_ID="tree-$(date +%Y%m%d-%H%M%S)" -WORKSPACE="$(pwd)/.tree/${SESSION_ID}" +# Reuse parent workspace when running as a child node +if [ -n "${TREE_WORKSPACE}" ]; then + WORKSPACE="${TREE_WORKSPACE}" +else + SESSION_ID="tree-$(date +%Y%m%d-%H%M%S)" + WORKSPACE="$(pwd)/.tree/${SESSION_ID}" +fi mkdir -p "${WORKSPACE}/root" ``` @@ -61,7 +66,7 @@ For each subtask, create the child's task file and launch it. ```bash mkdir -p "${WORKSPACE}/root-1" # Write the task file -cat > "${WORKSPACE}/root-1/task.md" << 'EOF' +cat > "${WORKSPACE}/root-1/task.md" << EOF TREE_TASK: {detailed subtask description with full context} TREE_NODE: root-1 TREE_DEPTH: 1 @@ -74,7 +79,7 @@ EOF Then spawn the child solver process: ```bash -claude -p "$(cat "${WORKSPACE}/root-1/task.md")" --agent tree-solver --model "${MODEL}" --max-turns 30 > "${WORKSPACE}/root-1/output.log" 2>&1 & +TREE_WORKSPACE="${WORKSPACE}" claude -p "$(cat "${WORKSPACE}/root-1/task.md")" --append-system-prompt "Use the /tree-solve skill to decompose and solve this subtask." --model "${MODEL}" --max-turns 30 > "${WORKSPACE}/root-1/output.log" 2>&1 & ``` **IMPORTANT**: Launch independent children in the background with `&` and use `wait` to collect them all.