agentleFS
dlupiakdlupiak/claude-session-dashboard/.claude/skills/analyze-skills/SKILL.md

analyze-skills

Skill71 starsChanged 9 months agoMITView on GitHub

Analyze ~/.claude session files to find unused agent skills and reduce context token waste. Scans subagent JSONL files for injected skills and cross-references with agent responses.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If $ARGUMENTS.project is provided, filter paths containing that project name.

    line 26
  2. Distinctive:

    If not provided, use the current working directory to determine the project.

    line 27
  3. Very specific:

    Read all agent files from .claude/agents/*.md in the current project.

    line 31
  4. Very specific:

    Look at the first user message — it usually contains the task description from the Task tool prompt.

    line 40
  5. Very specific:

    Search the first 20 lines for <command-name>SKILL_NAME</command-name> markers.

    line 43
  6. Very specific:

    Read the skill's SKILL.md file

    line 83
  7. Distinctive:

    After presenting the report, use AskUserQuestion to ask: "Would you like me to apply the recommended changes to the agent configuration …

    line 112
  8. Very specific:

    If yes, update the .claude/agents/*.md files with the optimized skill lists.

    line 115
  9. Distinctive:

    Always show the data before recommending changes

    line 124
  10. Distinctive:

    Consider that some skills may be critical for rare but important tasks — flag these as REVIEW rather than REMOVE

    line 125

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Analyze Agent Skill Usage

You are analyzing Claude Code session files to determine which agent skills are actually used vs wasted context tokens.

What This Does

Scans ~/.claude/projects/ for subagent JSONL files, detects which skills were injected into each agent, and checks whether the agent actually referenced that skill's content. Produces a report with recommendations to optimize agent configurations.

Step 1: Find Subagent Files

Find all subagent JSONL files for the target project:

# If project argument provided, filter by it. Otherwise use current project.
# Subagent files live at: ~/.claude/projects/<encoded-path>/<session-id>/subagents/agent-*.jsonl
find ~/.claude/projects/ -path "*/subagents/agent-*.jsonl" -type f 2>/dev/null

If $ARGUMENTS.project is provided, filter paths containing that project name. If not provided, use the current working directory to determine the project.

Step 2: Read Agent Definitions

Read all agent files from .claude/agents/*.md in the current project. Extract:

  • Agent name (from frontmatter name:)
  • Skills list (from frontmatter skills:)

Step 3: Analyze Each Subagent File

For each subagent JSONL file:

3a. Identify the agent type

Look at the first user message — it usually contains the task description from the Task tool prompt. Cross-reference with the parent session if needed.

3b. Extract injected skills

Search the first 20 lines for <command-name>SKILL_NAME</command-name> markers. This tells you which skills were loaded into the agent's context.

3c. Check skill usage

For each injected skill, search the agent's assistant messages for distinctive keywords:

SkillKeywords to search for
uiuxgray-950, terracotta, design system, bg-gray, border-gray
tanstack-startcreateServerFn, server function, TanStack Start, SSR
typescript-rulesstrict typing, Zod, z.object, z.infer, unknown, type guard
react-rulesuseQuery, useSuspenseQuery, queryOptions, named export, TanStack Query
testingvitest, describe, it, expect, vi.mock, happy-dom, testing-library
playwright-cliplaywright, browser, e2e, spec.ts, page.goto
sdlcpipeline, SDLC, acceptance criteria

A skill is "used" if ANY of its keywords appear in the agent's assistant responses.

Step 4: Build Usage Matrix

Aggregate results into a table:

Agent Type | Skill | Injected | Used | Usage % | Recommendation
-----------|-------|----------|------|---------|---------------
architect  | tanstack-start | 15 | 8 | 53% | KEEP
...

Step 5: Generate Report

Output a structured report with:

5a. Per-Agent Summary

For each agent type, show:

  • Current skills (from .claude/agents/<name>.md)
  • Usage rates from session data
  • Recommended changes (KEEP / REMOVE / ADD)

5b. Token Savings Estimate

For each removed skill, estimate context tokens saved:

  • Read the skill's SKILL.md file
  • Count approximate tokens (chars / 4)
  • Multiply by number of agent invocations

5c. Actionable Changes

List the exact frontmatter changes needed for each agent file. Example:

# .claude/agents/implementer.md — BEFORE
skills:
  - tanstack-start
  - typescript-rules
  - react-rules
  - uiux              # REMOVE (3% usage, ~1.5K tokens wasted per invocation)

# .claude/agents/implementer.md — AFTER
skills:
  - tanstack-start
  - typescript-rules
  - react-rules

5d. Skills Not Assigned to Any Agent

List skills in .claude/skills/ that are NOT in any agent's frontmatter. These are either:

  • Main-context-only skills (like /feature, /review) — expected
  • Potentially useful skills missing from agents — flag for review

Step 6: Ask User

After presenting the report, use AskUserQuestion to ask: "Would you like me to apply the recommended changes to the agent configuration files?"

If yes, update the .claude/agents/*.md files with the optimized skill lists.

Important Rules

  • Read-only for ~/.claude — never modify files in ~/.claude/
  • Agent config files (.claude/agents/*.md) are in the project — those CAN be modified
  • Base recommendations on data, not assumptions
  • A skill with < 15% usage rate across 5+ invocations is a REMOVE candidate
  • A skill with 0% usage across ANY number of invocations is a definite REMOVE
  • Always show the data before recommending changes
  • Consider that some skills may be critical for rare but important tasks — flag these as REVIEW rather than REMOVE

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.