tendril-debug-plan
Debug and analyze Tendril plan executions end-to-end - from plan creation through checking/verification - and produce a set of concrete bugfix and improvement recommendations.
Invocation
/tendril-debug-plan <planid> <note>
- planid - 5-digit Tendril plan ID (e.g.,
03451)
- note - free-text context about what to look for (e.g., "verification passed but shouldn't have", "took forever", "got stuck in Building state")
What This Skill Does
- Gathers all artifacts for a plan:
plan.yaml, revisions, logs, costs, verification reports, session JSONL
- Analyzes the execution timeline, token usage, tool call patterns, and error loops
- Cross-references findings with Tendril source code and promptware instructions
- Produces a structured recommendations report with concrete fixes
Execution Steps
Phase 1 - Gather Plan Artifacts
Resolve paths from environment:
TENDRIL_HOME - base config/data directory
TENDRIL_PLANS - plans directory (defaults to $TENDRIL_HOME/Plans)
REPOS_HOME - for locating Tendril source code
Read these files from the plan folder ($TENDRIL_PLANS/{planid}-*/):
| File |
Purpose |
plan.yaml |
Plan metadata: state, repos, commits, PRs, verifications, dependsOn |
revisions/*.md |
Plan scope, acceptance criteria, verification checkboxes. Last one is the one that is the executable one. |
costs.csv |
Token/cost breakdown per promptware (if available) |
verification/*.md |
Verification reports (PreExecution, IvyFrameworkVerification, etc.) |
worktrees/ |
Check if worktrees were created/cleaned up |
The plan folder holds no logs. Every job that ran against the plan wrote its artifacts flat into
$TENDRIL_HOME/Jobs/, named {jobId}-{planId}-{promptware}. Find them all for a plan with:
ls "$TENDRIL_HOME/Jobs/"*"-{planid}-"*
| File |
Purpose |
{stem}.md |
Job Log - status, timings, cost, CLI command, final output, agent ## Agent Log narrative |
{stem}.prompt.md |
Job Prompt - the exact prompt handed to the agent |
{stem}.raw.jsonl |
Job Raw Log - full unparsed CLI session data |
{stem}.eventwire.jsonl |
Job Eventwire Log - Tendril's parsed event stream |
Note that the CreatePlan job that created the plan is named {jobId}-CreatePlan with no plan id,
so it will not appear in the glob above. Use /tendril-debug-job to drill into any single job.
Phase 2 - Locate and Analyze Session JSONL
Each Job Log contains a SessionId. The raw Claude session data lives at:
~/.claude/projects/*/{SessionId}.jsonl
Use find ~/.claude/projects -name "{SessionId}.jsonl" to locate each file.
For each JSONL session, extract:
Token Usage:
- Sum
input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens from type: "assistant" messages
- Cache hit ratio:
cache_read / (cache_read + cache_creation + input)
- Flag messages with unusually high
input_tokens (context bloat)
Tool Call Patterns:
- Count each tool type (Read, Write, Edit, Bash, Grep, Glob)
- Identify repeated reads of the same file (redundant)
- Identify failed tool calls and their errors
- Detect thrashing: read-edit-read-edit cycles on the same file
Error Patterns:
- Grep for
error, failed, exception, timeout in tool results
- Count compilation fix-retry cycles (build → error → edit → build loops)
- Permission errors, missing files, environmental issues
Time Analysis:
- Wall-clock duration from first to last timestamp
- Long gaps between messages (slow tools, rate limiting)
- Timeout detection
Use the Analyze-SessionJsonl.ps1 tool if available at:
$REPOS_HOME/Ivy-Tendril/src/Ivy.Tendril.TeamIvyConfig/Promptwares/PlanEvaluator/Tools/Analyze-SessionJsonl.ps1
Phase 3 - Analyze the Checking/Verification Pipeline
This is the core debugging focus. Examine:
Pre-execution checks (ExecutePlan Step 1.5–1.8):
- Did dependency checking work correctly? (
dependsOn plans completed, PRs merged)
- Did worktree validation catch problems? Or miss them?
- Did code state validation (
**Current implementation** blocks) match reality?
- Did auto-commit handle dirty files properly?
Verification execution (ExecutePlan Step 7):
- Which verifications ran vs were skipped?
- Did verifications match what the plan revision checkboxes specified?
- For each verification: did the prompt execute correctly? Were failures diagnosed?
- How many fix-retry cycles occurred (max 3 allowed)?
- Were verification results written to
verification/ correctly?
- Were plan verification statuses updated via
tendril plan set-verification?
Post-verification (ExecutePlan Step 7.5–8):
- Were recommendations generated?
- Was the worktree left clean?
- Were zombie processes detected/killed?
CheckResult / completion verification (JobService):
- For CreatePlan: did
VerifyCreatePlanResult find the plan folder or the identified as duplicate: marker?
- Did
CheckDependencies correctly evaluate dependency plan states?
- Did
TryBlockForDependencies transition appropriately?
Cross-reference each finding with:
Promptwares/{Type}/Program.md - could instructions prevent this?
Promptwares/{Type}/Memory/ - is knowledge missing or ignored?
Services/JobService.cs - job lifecycle issues
Services/PlanReaderService.cs - plan state/repair issues
Ivy.Tendril/Assets/Plans.md - plan schema/CLI reference (embedded in assembly, injected into firmware)
Phase 4 - Produce Recommendations Report
Write the report to $TENDRIL_PLANS/{planid}-*/debug-report.md (alongside the plan).
Use this format:
# Debug Report: {PlanId} - {Title}
- **Analyzed:** {current timestamp}
- **Plan State:** {state}
- **User Note:** {the note argument}
- **Promptwares Run:** {list}
- **Total Tokens:** {sum}
- **Wall-Clock Time:** {duration}
## Executive Summary
{3-5 sentences: what happened, what went wrong, what's the root cause}
## Timeline
| # | Step | Promptware | Status | Duration | Tokens | Notes |
|---|------|------------|--------|----------|--------|-------|
| 1 | CreatePlan | CreatePlan | Completed | 2m30s | 45k | - |
| 2 | Execute | ExecutePlan | Failed | 15m | 280k | build loop |
| ... | | | | | | |
## Checking & Verification Analysis
### Pre-Execution Checks
{What passed, what failed, what was missed}
### Verification Results
| Verification | Expected | Actual | Correct? | Notes |
|-------------|----------|--------|----------|-------|
| Build | Pass | Pass | Yes | - |
| IvyFramework | Pass | Pass | No | Should have caught X |
### Completion Verification
{How JobService verified the result, any gaps}
## Findings
### {Finding Title}
- **Category:** {Token Waste | Error Loop | Missing Knowledge | Instruction Gap | Environmental | Architectural | Verification Gap}
- **Severity:** {Low | Medium | High | Critical}
- **Promptware:** {which one}
- **Evidence:** {specific log lines, timestamps, tool call IDs}
{Description with specific evidence.}
**Root Cause:** {why this happened}
**Recommendation:** {concrete fix - which file to change, what to change, why}
---
{Repeat for each finding}
## Concrete Fixes
Priority-ordered list of specific changes:
1. **[High] {file path}**: {what to change and why}
2. **[Medium] {file path}**: {what to change and why}
3. ...
## Skill Self-Improvement Notes
{If this analysis revealed patterns or techniques that would make future debugging faster,
note them here. These will be incorporated into the skill's references/ directory.}
Key Tendril Files for Cross-Reference
These are the files most likely to contain the root cause of issues:
| File |
What It Controls |
Services/JobService.cs |
Job lifecycle, dependency checking, completion verification |
Services/JobLauncher.cs |
Job launch, CLI shim generation, firmware value population |
Services/JobCompletionHandler.cs |
Post-completion: logs, raw output, plan state, telemetry |
Services/PlanReaderService.cs |
Plan state transitions, repair logic, stuck plan recovery |
Services/GitService.cs |
Worktree creation/cleanup, commit operations |
Services/Agents/FirmwareCompiler.cs |
Prompt compilation, log file allocation |
Promptwares/ExecutePlan/Program.md |
Main execution flow, all verification steps |
Promptwares/CreatePlan/Program.md |
Plan creation, folder setup |
Ivy.Tendril/Assets/Plans.md |
Plan schema, CLI commands, state lifecycle (embedded resource) |
Promptwares/{Type}/Memory/ |
Agent knowledge base per promptware |
Models/PlanModels.cs |
Plan deserialization model |
Helpers/PlanContentHelpers.cs |
Commit row building, plan content rendering |
Rules
- Read-only by default: do NOT modify source code, promptware instructions, or memory files during analysis. The output is a recommendations report.
- Always produce a report, even if no issues are found - "plan executed cleanly" is a valid finding.
- Be specific: cite file paths, line numbers, log timestamps, tool call sequences.
- Focus on the checking pipeline: verification gaps (things that should have been caught but weren't) are higher priority than token waste.
- Use targeted reads: JSONL files can be huge - use offset/limit or grep rather than reading entire files.
- The user's note is your guide: prioritize investigating what the user flagged.
Self-Evolution
This skill is designed to improve over time. After producing a report:
- If you discovered a new debugging pattern or common failure mode not covered here, write it to
references/{topic}.md
- If a cross-reference path was wrong or a file moved, update the paths in this SKILL.md
- If the report format could be improved based on what you learned, update the template above
The references/ directory accumulates knowledge from past debugging sessions.
1---2name: tendril-debug-plan3description: Debug a Tendril plan by analyzing its execution logs, session JSONL, verification results, and checking infrastructure. Produces actionable bugfix and improvement recommendations. Use when the user wants to investigate why a plan failed, behaved unexpectedly, or to audit plan execution quality.4---56# tendril-debug-plan78Debug and analyze Tendril plan executions end-to-end - from plan creation through checking/verification - and produce a set of concrete bugfix and improvement recommendations.910## Invocation1112```13/tendril-debug-plan <planid> <note>14```1516* **planid** - 5-digit Tendril plan ID (e.g., `03451`)17* **note** - free-text context about what to look for (e.g., "verification passed but shouldn't have", "took forever", "got stuck in Building state")1819## What This Skill Does20211. Gathers all artifacts for a plan: `plan.yaml`, revisions, logs, costs, verification reports, session JSONL222. Analyzes the execution timeline, token usage, tool call patterns, and error loops233. Cross-references findings with Tendril source code and promptware instructions244. Produces a structured recommendations report with concrete fixes2526## Execution Steps2728### Phase 1 - Gather Plan Artifacts2930Resolve paths from environment:3132* `TENDRIL_HOME` - base config/data directory33* `TENDRIL_PLANS` - plans directory (defaults to `$TENDRIL_HOME/Plans`)34* `REPOS_HOME` - for locating Tendril source code3536Read these files from the plan folder (`$TENDRIL_PLANS/{planid}-*/`):3738| File | Purpose |39| ------------------- | ---------------------------------------------------------------------------------------------------------- |40| `plan.yaml` | Plan metadata: state, repos, commits, PRs, verifications, dependsOn |41| `revisions/*.md` | Plan scope, acceptance criteria, verification checkboxes. Last one is the one that is the executable one. |42| `costs.csv` | Token/cost breakdown per promptware (if available) |43| `verification/*.md` | Verification reports (PreExecution, IvyFrameworkVerification, etc.) |44| `worktrees/` | Check if worktrees were created/cleaned up |4546The plan folder holds **no logs**. Every job that ran against the plan wrote its artifacts flat into47`$TENDRIL_HOME/Jobs/`, named `{jobId}-{planId}-{promptware}`. Find them all for a plan with:4849```bash50ls "$TENDRIL_HOME/Jobs/"*"-{planid}-"*51```5253| File | Purpose |54|------|---------|55| `{stem}.md` | Job Log - status, timings, cost, CLI command, final output, agent `## Agent Log` narrative |56| `{stem}.prompt.md` | Job Prompt - the exact prompt handed to the agent |57| `{stem}.raw.jsonl` | Job Raw Log - full unparsed CLI session data |58| `{stem}.eventwire.jsonl` | Job Eventwire Log - Tendril's parsed event stream |5960Note that the `CreatePlan` job that created the plan is named `{jobId}-CreatePlan` with **no** plan id,61so it will not appear in the glob above. Use `/tendril-debug-job` to drill into any single job.6263### Phase 2 - Locate and Analyze Session JSONL6465Each Job Log contains a `SessionId`. The raw Claude session data lives at:6667```68~/.claude/projects/*/{SessionId}.jsonl69```7071Use `find ~/.claude/projects -name "{SessionId}.jsonl"` to locate each file.7273For each JSONL session, extract:7475**Token Usage:**7677* Sum `input_tokens`, `output_tokens`, `cache_read_input_tokens`, `cache_creation_input_tokens` from `type: "assistant"` messages78* Cache hit ratio: `cache_read / (cache_read + cache_creation + input)`79* Flag messages with unusually high `input_tokens` (context bloat)8081**Tool Call Patterns:**8283* Count each tool type (Read, Write, Edit, Bash, Grep, Glob)84* Identify repeated reads of the same file (redundant)85* Identify failed tool calls and their errors86* Detect thrashing: read-edit-read-edit cycles on the same file8788**Error Patterns:**8990* Grep for `error`, `failed`, `exception`, `timeout` in tool results91* Count compilation fix-retry cycles (build → error → edit → build loops)92* Permission errors, missing files, environmental issues9394**Time Analysis:**9596* Wall-clock duration from first to last timestamp97* Long gaps between messages (slow tools, rate limiting)98* Timeout detection99100Use the `Analyze-SessionJsonl.ps1` tool if available at:101102```103$REPOS_HOME/Ivy-Tendril/src/Ivy.Tendril.TeamIvyConfig/Promptwares/PlanEvaluator/Tools/Analyze-SessionJsonl.ps1104```105106### Phase 3 - Analyze the Checking/Verification Pipeline107108This is the core debugging focus. Examine:109110**Pre-execution checks (ExecutePlan Step 1.5–1.8):**111112* Did dependency checking work correctly? (`dependsOn` plans completed, PRs merged)113* Did worktree validation catch problems? Or miss them?114* Did code state validation (`**Current implementation**` blocks) match reality?115* Did auto-commit handle dirty files properly?116117**Verification execution (ExecutePlan Step 7):**118119* Which verifications ran vs were skipped?120* Did verifications match what the plan revision checkboxes specified?121* For each verification: did the prompt execute correctly? Were failures diagnosed?122* How many fix-retry cycles occurred (max 3 allowed)?123* Were verification results written to `verification/` correctly?124* Were plan verification statuses updated via `tendril plan set-verification`?125126**Post-verification (ExecutePlan Step 7.5–8):**127128* Were recommendations generated?129* Was the worktree left clean?130* Were zombie processes detected/killed?131132**CheckResult / completion verification (JobService):**133134* For CreatePlan: did `VerifyCreatePlanResult` find the plan folder or the `identified as duplicate:` marker?135* Did `CheckDependencies` correctly evaluate dependency plan states?136* Did `TryBlockForDependencies` transition appropriately?137138Cross-reference each finding with:139140* `Promptwares/{Type}/Program.md` - could instructions prevent this?141* `Promptwares/{Type}/Memory/` - is knowledge missing or ignored?142* `Services/JobService.cs` - job lifecycle issues143* `Services/PlanReaderService.cs` - plan state/repair issues144* `Ivy.Tendril/Assets/Plans.md` - plan schema/CLI reference (embedded in assembly, injected into firmware)145146### Phase 4 - Produce Recommendations Report147148Write the report to `$TENDRIL_PLANS/{planid}-*/debug-report.md` (alongside the plan).149150Use this format:151152```Markdown153# Debug Report: {PlanId} - {Title}154155- **Analyzed:** {current timestamp}156- **Plan State:** {state}157- **User Note:** {the note argument}158- **Promptwares Run:** {list}159- **Total Tokens:** {sum}160- **Wall-Clock Time:** {duration}161162## Executive Summary163164{3-5 sentences: what happened, what went wrong, what's the root cause}165166## Timeline167168| # | Step | Promptware | Status | Duration | Tokens | Notes |169|---|------|------------|--------|----------|--------|-------|170| 1 | CreatePlan | CreatePlan | Completed | 2m30s | 45k | - |171| 2 | Execute | ExecutePlan | Failed | 15m | 280k | build loop |172| ... | | | | | | |173174## Checking & Verification Analysis175176### Pre-Execution Checks177{What passed, what failed, what was missed}178179### Verification Results180| Verification | Expected | Actual | Correct? | Notes |181|-------------|----------|--------|----------|-------|182| Build | Pass | Pass | Yes | - |183| IvyFramework | Pass | Pass | No | Should have caught X |184185### Completion Verification186{How JobService verified the result, any gaps}187188## Findings189190### {Finding Title}191192- **Category:** {Token Waste | Error Loop | Missing Knowledge | Instruction Gap | Environmental | Architectural | Verification Gap}193- **Severity:** {Low | Medium | High | Critical}194- **Promptware:** {which one}195- **Evidence:** {specific log lines, timestamps, tool call IDs}196197{Description with specific evidence.}198199**Root Cause:** {why this happened}200201**Recommendation:** {concrete fix - which file to change, what to change, why}202203---204205{Repeat for each finding}206207## Concrete Fixes208209Priority-ordered list of specific changes:2102111. **[High] {file path}**: {what to change and why}2122. **[Medium] {file path}**: {what to change and why}2133. ...214215## Skill Self-Improvement Notes216217{If this analysis revealed patterns or techniques that would make future debugging faster,218note them here. These will be incorporated into the skill's references/ directory.}219```220221## Key Tendril Files for Cross-Reference222223These are the files most likely to contain the root cause of issues:224225| File | What It Controls |226| -------------------------------------------------- | ----------------------------------------------------------- |227| `Services/JobService.cs` | Job lifecycle, dependency checking, completion verification |228| `Services/JobLauncher.cs` | Job launch, CLI shim generation, firmware value population |229| `Services/JobCompletionHandler.cs` | Post-completion: logs, raw output, plan state, telemetry |230| `Services/PlanReaderService.cs` | Plan state transitions, repair logic, stuck plan recovery |231| `Services/GitService.cs` | Worktree creation/cleanup, commit operations |232| `Services/Agents/FirmwareCompiler.cs` | Prompt compilation, log file allocation |233| `Promptwares/ExecutePlan/Program.md` | Main execution flow, all verification steps |234| `Promptwares/CreatePlan/Program.md` | Plan creation, folder setup |235| `Ivy.Tendril/Assets/Plans.md` | Plan schema, CLI commands, state lifecycle (embedded resource) |236| `Promptwares/{Type}/Memory/` | Agent knowledge base per promptware |237| `Models/PlanModels.cs` | Plan deserialization model |238| `Helpers/PlanContentHelpers.cs` | Commit row building, plan content rendering |239240## Rules241242* **Read-only by default**: do NOT modify source code, promptware instructions, or memory files during analysis. The output is a recommendations report.243* **Always produce a report**, even if no issues are found - "plan executed cleanly" is a valid finding.244* **Be specific**: cite file paths, line numbers, log timestamps, tool call sequences.245* **Focus on the checking pipeline**: verification gaps (things that should have been caught but weren't) are higher priority than token waste.246* **Use targeted reads**: JSONL files can be huge - use offset/limit or grep rather than reading entire files.247* **The user's note is your guide**: prioritize investigating what the user flagged.248249## Self-Evolution250251This skill is designed to improve over time. After producing a report:2522531. If you discovered a new debugging pattern or common failure mode not covered here, write it to `references/{topic}.md`2542. If a cross-reference path was wrong or a file moved, update the paths in this SKILL.md2553. If the report format could be improved based on what you learned, update the template above256257The `references/` directory accumulates knowledge from past debugging sessions.