Skip to content

docs(skills): Add symptom-based troubleshooting guidance - #2469

Open
karangattu wants to merge 27 commits into
mainfrom
feat-shiny-doctor-skill
Open

karangattu wants to merge 27 commits into
mainfrom
feat-shiny-doctor-skill

Conversation

@karangattu

@karangattu karangattu commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

The bundled shiny-for-python Agent Skill now routes misbehaving apps to symptom-based troubleshooting guidance. Agents can find likely causes for blank outputs, stale values, frozen sessions, and state leaks, read the relevant topic guide, then verify the repair through a connected browser session.

Key changes

  • Add one references/troubleshooting.md with a symptom index and a repair/verification workflow. Distinguish symptom diagnosis from observing live state and testing a fix.
  • Put Core output-ID and duplicate-ID guidance in the existing dynamic-ui.md Common mistakes section; route blank-output and duplicate-ID symptoms there.
  • Put reactive-call and collection-update examples in reactivity.md, state isolation in session-lifecycle.md, blocking-work guidance in extended-tasks.md, and R-to-Python syntax in express.md. Link to the existing module guidance for namespace issues.
  • Expand the Express guide with shared initialization, per-session state, and automatic display guidance.
  • Keep verification reporting explicit: Runtime Verified (Session Level), Server Startup Verified, or Static Diagnosis Only.
Earlier SkillDiff evaluation (control vs treatment)

This preliminary comparison evaluated the earlier standalone shiny-doctor skill, before its guidance was integrated into shiny-for-python. It used gpt-6-sol with one control/treatment pair per task.

Each arm received a fresh copy of the same broken app. The grader was outside the fixture and checked connected Shiny browser sessions after the agent finished.

Scenario Untouched Control Score Skill Score Control Time Skill Time Control Tokens Skill Tokens Δ Time Δ Tokens
Operations Dashboard 3/8 8/8 (100%) 8/8 (100%) 367s 321s 1.93M 1.59M -46s (-12.5%) -340k (-17.6%)
Shift Handoff Board 4/9 9/9 (100%) 9/9 (100%) 303s 235s 1.76M 1.13M -68s (-22.4%) -630k (-35.8%)
Express Energy 4/10 10/10 (100%) 10/10 (100%) 303s 160s 2.44M 0.71M -143s (-47.2%) -1.73M (-70.9%)
Total / Overall 11/27 (40.7%) 27/27 (100%) 27/27 (100%) 972s 716s 6.13M 3.44M -256s (-26.3%) -2.69M (-43.9%)

These three pairs reached the same correctness scores. Treatment used fewer tokens and finished sooner in each pair. This small comparison does not establish performance gains for the integrated skill.

Validation

  • uv run --no-sync pytest tests/pytest/test_agent_skills_sync.py tests/pytest/test_main_skills.py tests/pytest/test_packaging.py -n 0: 15 passed, including a fresh wheel build and the reference-index contract.
  • Skill frontmatter validation passed; checked 36 Python examples and 25 local Markdown links/anchors in the revised guides.
  • Executed the moved output-ID example with test_server; the expected output matched.
  • git diff --check passed.
  • Earlier repository-wide checks encountered lint errors in an ignored local app, missing optional dependencies, and existing type errors in unchanged Python files.

@karangattu
karangattu marked this pull request as draft August 25, 2026 03:24
@karangattu
karangattu marked this pull request as ready for review October 1, 2026 18:10
@karangattu
karangattu requested a review from cpsievert October 1, 2026 18:11
Comment thread shiny/.agents/skills/shiny-doctor/SKILL.md Outdated
Comment thread shiny/.agents/skills/shiny-for-python/references/antipatterns.md Outdated
Comment thread shiny/.agents/skills/shiny-doctor/SKILL.md Outdated
Comment thread shiny/.agents/skills/shiny-for-python/references/antipatterns.md Outdated
Comment thread shiny/.agents/skills/shiny-doctor/references/antipatterns.md Outdated
Comment thread shiny/.agents/skills/shiny-for-python/references/antipatterns.md Outdated
Comment thread shiny/.agents/skills/shiny-for-python/references/antipatterns.md Outdated

@cpsievert cpsievert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Five comments are inline on the diff. Two more below target files that are not in this PR, so they live here in the review body.


A pointer back from shiny-for-python (shiny/.agents/skills/shiny-for-python/SKILL.md, the index tables — not in this diff)

Right now nothing in shiny-for-python mentions shiny-doctor. Routing works in one direction only. What do you think about one line in the index, something like "To audit an existing app for quality, use the shiny-doctor skill"? It helps an agent that loaded the wrong skill find the right one.


agent-skills.md needs an update in this PR (.claude/references/agent-skills.md, the opening paragraph and "Layout" — not in this diff)

This doc says the package ships "a single Agent Skill" and "There is one skill directory". It also says "Adding a new topic does not mean creating a new top-level skill directory." This PR adds a second skill, which I think is reasonable: auditing an existing app is a different trigger than building one. But the doc now contradicts the repo. Can we update it here, in the same PR? A short paragraph on when a second skill is warranted, versus adding a references/<topic>.md file, will help the next contributor decide without guessing.

Comment thread shiny/.agents/skills/shiny-doctor/SKILL.md Outdated
Comment thread shiny/.agents/skills/shiny-doctor/SKILL.md Outdated
Comment thread shiny/.agents/skills/shiny-for-python/references/antipatterns.md Outdated
Comment thread shiny/.agents/skills/shiny-doctor/SKILL.md Outdated
Comment thread tests/pytest/test_agent_skills_sync.py Outdated
@karangattu

karangattu commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator Author

I ran skilldiff using gpt-sol 6.1 and it shows that skills actually slow down and cost more. :|

App Arm Checks Time Uncached input tokens Cached input tokens Output tokens Total tokens
Core trading Without skill 11/11 238.67s 27,911 217,728 6,641 252,280
Core trading With shiny-doctor 11/11 240.31s 20,749 225,920 7,037 253,706
Express research Without skill (rerun) 11/11 283.01s 24,357 258,944 7,939 291,240
Express research With shiny-doctor 11/11 288.59s 47,620 395,392 7,655 450,667

using gpt Luna 6

App Arm Score Time Input Cached input Output Total tokens Tool calls Skill loaded API-equivalent cost
Express research Without skill 11/11 (100%) 210.93s 33,367 456,192 9,931 499,490 21 No $0.0129
Express research With skill 11/11 (100%) 239.39s 46,155 591,872 11,235 649,262 23 Yes $0.0162
Core trading Without skill 9/11 (82%) 204.62s 42,043 456,192 9,871 508,106 19 No $0.0137
Core trading With skill 11/11 (100%) 378.09s 73,616 1,570,560 16,857 1,661,033 34 Yes $0.0315

@cpsievert

Copy link
Copy Markdown
Collaborator

I ran skilldiff

I could use some help understanding more of the surrounding context here. Is this something that has gotten worse with our recent changes? These look like different apps than what you included in the PR description?

Generally speaking, it's not totally surprising to me that using a skill would be more costly, but hopefully the result is better (potentially in a way that's hard for the LLM to actually measure)?

@karangattu

karangattu commented Oct 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

I ran skilldiff

I could use some help understanding more of the surrounding context here. Is this something that has gotten worse with our recent changes? These look like different apps than what you included in the PR description?

Generally speaking, it's not totally surprising to me that using a skill would be more costly, but hopefully the result is better (potentially in a way that's hard for the LLM to actually measure)?

I was curious why that is happening, so I had to look into the logs

  1. SKILL.md Step 1 instructed: "Discover installed capabilities with shiny --help. If available, read shiny validate --help and run it..." shiny validate does not exist YET in Shiny (Python) since that PR is on a separate branch. Every model wasted 1–2 turns, generated errors (Error: No such command 'validate') and spent turns trying to diagnose missing CLI tools.
  2. SKILL.md tells agents in Step 3 to “Consult the Antipatterns Catalog.”
    In practice, every model interpreted that as a command to run cat references/antipatterns.md, usually by turn 2 or 3. That file is 515 lines long (~4,500 tokens).
    That turned a one-time reference lookup into a major source of wasted context, adding roughly 150,000 up to 650,000 redundant tokens per session.
  3. Links pointing to ../../shiny-for-python/references/... caused 404/file-not-found errors during isolated runs, wasting tool turns. In agent harness (Claude Code), agents load skills by name and trigger description, not by reading arbitrary files from sibling directories. Each agent skill should be an independent, self-sufficient package. It should never depend on relative filesystem traversal into another skill.
    So we can integrate shiny-doctor into the main shiny-for-python skill as a reference

@karangattu

Copy link
Copy Markdown
Collaborator Author

If we do not do the traversal across 2 different skills using path, the results get better slightly.

App Arm Score Time Input Cached input Output Total tokens Tool calls Turns Skill loaded
research (gpt-6.1-sol) Control 100% 269s N/A N/A N/A N/A 15 1 no
research (gpt-6.1-sol) Skill 100% 228s N/A N/A N/A N/A 15 1 yes
research (gpt-6.1-sol) Δ (Skill − Control) 0 pp −41s N/A N/A N/A N/A 0 0  
trading (gpt-6.1-sol) Control 100% 298s N/A N/A N/A N/A 13 1 no
trading (gpt-6.1-sol) Skill 100% 278s N/A N/A N/A N/A 17 1 yes
trading (gpt-6.1-sol) Δ (Skill − Control) 0 pp −20s N/A N/A N/A N/A +4 0  
research (gpt-6-luna) Control 100% 232s N/A N/A N/A N/A 24 1 no
research (gpt-6-luna) Skill 100% 248s N/A N/A N/A N/A 26 1 yes
research (gpt-6-luna) Δ (Skill − Control) 0 pp +16s N/A N/A N/A N/A +2 0  
trading (gpt-6-luna) Control 100% 251s N/A N/A N/A N/A 18 1 no
trading (gpt-6-luna) Skill 100% 487s N/A N/A N/A N/A 35 1 yes
trading (gpt-6-luna) Δ (Skill − Control) 0 pp +236s N/A N/A N/A N/A +17 0  
research (gemini-3.8-flash-high) Control 100% 499s N/A N/A N/A N/A N/A 1 no
research (gemini-3.8-flash-high) Skill 100% 263s N/A N/A N/A N/A N/A 1 yes
research (gemini-3.8-flash-high) Δ (Skill − Control) 0 pp −236s N/A N/A N/A N/A N/A 0  
trading (gemini-3.8-flash-high) Control 100% 344s N/A N/A N/A N/A N/A 1 no
trading (gemini-3.8-flash-high) Skill 100% 216s N/A N/A N/A N/A N/A 1 yes
trading (gemini-3.8-flash-high) Δ (Skill − Control) 0 pp −128s N/A N/A N/A N/A N/A 0  

@cpsievert
cpsievert self-requested a review October 7, 2026 15:56

@cpsievert cpsievert left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My recommendation: consolidate the three new files into a single references/troubleshooting.md, and move the antipattern examples into the "Common mistakes" sections of the existing topic references.

Concretely:

  1. Distribute antipatterns.md — sections 1–4 go to reactivity.md, 5 to session-lifecycle.md, 6 to extended-tasks.md, 7–8 to an outputs/core reference, 9 to the modules references, 10–11 to express.md. Each pitfall then lives where the agent is already working when it's most likely to make the mistake.
  2. Keep one troubleshooting.md — the symptom → cause → fix table, with rows pointing into the topic references, plus the runtime-verification workflow. One new row in SKILL.md: "An existing app misbehaves — blank outputs, stale values, cross-session leakage, frozen sessions, ID mismatches."
  3. Drop or fold in the checklist — it's a third restatement of the same items.

Why I think this works better:

  • It removes duplication. Most of antipatterns.md already exists in the skill's "Common mistakes" sections — §3 is in reactivity.md, §5 in session-lifecycle.md, §6 in extended-tasks.md, §9 in modules-core.md, §10 in express.md. This PR even adds the same Express shared-objects guidance to both express.md and antipatterns.md. Two homes for the same content will drift.
  • "Troubleshooting" is a better trigger than "Shiny Doctor." Every other reference is named for a task; a persona doesn't tell the agent when to load the file. A symptom-first row ("an existing app misbehaves") is something the agent can actually match against the user's situation.
  • One file instead of three means one obvious place to look, and less to maintain.

To be clear about what I'd keep as-is: the content itself is good — the uncalled-reactive, in-place-mutation, @output(id=...), and R-syntax material is genuinely new, and the verification workflow with its "Runtime Verified / Static Diagnosis Only" reporting levels is excellent. This is purely about placement. I'd also draw one explicit boundary while you're in there: troubleshooting routes from symptoms, debugging.md is the technique for observing live state, testing verifies the fix.

Comment thread .claude/references/agent-skills.md Outdated
Comment thread CHANGELOG.md Outdated
@karangattu karangattu changed the title feat(skills): Add shiny-doctor agent skill for LLM validation and app diagnostics docs(skills): Add app audit and repair guidance Oct 8, 2026
@karangattu karangattu changed the title docs(skills): Add app audit and repair guidance docs(skills): Add symptom-based troubleshooting guidance Oct 8, 2026
@karangattu

Copy link
Copy Markdown
Collaborator Author

using gpt 6.1 sol I ran skilldiff to see this table, which seems acceptable

App Arm Score Time Input Cached input Output Total tokens Tool calls Turns Skill loaded API-equivalent cost
research Control 100% 238s 31,777 266,624 7,747 306,148 19 1 no $0.17
research Skill 100% 254s 54,110 311,552 8,303 373,965 14 1 yes $0.22
research Δ (Skill - Control) 0 pp +16s +22,333 +44,928 +556 +67,817 -5 0   +$0.05
trading Control 100% 190s 22,016 139,392 6,071 167,479 13 1 no $0.12
trading Skill 100% 394s 35,715 452,864 8,352 496,931 20 1 yes $0.20
trading Δ (Skill - Control) 0 pp +204s +13,699 +313,472 +2,281 +329,452 +7 0   +$0.08

@karangattu

Copy link
Copy Markdown
Collaborator Author

When running with GPT 6.1 Sol with the same skill on main v/s the skill in this PR

App Arm Score Time Input Cached input Output Total tokens Tool calls Turns Skill loaded API-equivalent cost
stale-list Skill A (main) 100% 34s 13,546 73,728 469 87,743 6 1 yes ~$0.039
stale-list Skill B (PR) 100% 26s 9,066 83,328 474 92,868 6 1 yes ~$0.031
stale-list Δ (Skill B - Skill A) 0 pp -9s -4,480 +9,600 +5 +5,125 0 0 ~-$0.008

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants