tsa-refactor-queue

A tool that ranks files for refactoring by combining code-health grades, how often files change, and likely dead code. Refactoring means improving code structure without changing what it does.

In plain words
What is it for?
Use it during engineering triage, cleanup after new features, sprint planning, or after a code-health warning.
Why use it?
It turns a broad cleanup task into a short, ordered list of files and suggested actions.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/aimasteracc/tree-sitter-analyzer/tsa-refactor-queue
Any agent
npx skills add aimasteracc/tree-sitter-analyzer --skill tsa-refactor-queue
Clone the repo
git clone --depth 1 https://github.com/aimasteracc/tree-sitter-analyzer

Made for: Claude Code, Codex.

Per session 265 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,959 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00265 $0.02959
Opus 5 $0.00133 $0.01479
Sonnet 5 $0.00053 $0.00592
Haiku 4.5 $0.00026 $0.00296

Measured 3d ago against content hash 322a12e7604c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tsa-refactor-queue scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/tsa-refactor-queue/SKILL.md · 281 lines

How it starts

The opening of the file, as written. The whole thing — 281 lines — stays where its author put it; the contents beside it link to each section on GitHub.

tsa-refactor-queue — Top-N prioritized refactor slices

Three signals, one ranked list. Health × churn × dead-code → the five files you'd refactor first if you had a week. Each row carries a target symbol, a blast radius, and a concrete action.

When to use

  • "What should we refactor next?" — daily/weekly engineering triage
  • Post-feature cleanup pass — find rot that accumulated while shipping
  • Pre-sprint planning — turn "we should clean up" into 5 concrete tickets
  • After a CI grade-drop alert from tsa-health-watch — re-rank with churn

Don't use when:

  • You already know the file (one-file deep dive → health action=file or tsa-edit-safety)
  • The codebase is brand-new (<2 weeks of git history) — churn signal is noise
  • You want to optimize one hot function — use tsa-graph + edit action=refactor directly
  • Shallow clone in CI — git_state=shallow makes mod_count_30d unreliable

Procedure

Step 1 — Single fan-out (parallel, 3 MCP calls)

Call these in ONE message:

  1. health action=project with min_grade: "D" and max_files: 20 — F/D files + per-file weakest_dimension
  2. health action=dead with max_dead: 200 — symbol-level dead candidates, grouped by file
  3. health action=heatmap with top_n: 20 — complexity-weighted file list (covers structural smell)

The three responses overlap on file path. Joining on file_path gives a 3-signal table per candidate.

Step 2 — Score and rank (deterministic, no LLM needed)

For each file that appears in health action=project worst_files, compute:

priority = (1 - health_score/100)            # how bad is the grade
         * log(1 + mod_count_30d_for_file)   # how hot is the file
         * (dead_symbol_count / total_symbols + 0.1)

Where:

  • health_score ∈ [0,100] from health action=project (lower → worse → bigger weight)
  • mod_count_30d_for_file = sum of mod_count_30d across the file's symbols (read from ast_symbol_activation — see tsa-temporal). log(1+x) damps pathological churn so a single 50× file doesn't dominate.
  • dead_symbol_count / total_symbols = fraction of symbols health action=dead flagged. The + 0.1 floor ensures non-dead files can still rank if churn+grade alone justify it.

Read the full file on GitHub · 281 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 281 lines · 265 tokens per session scan A 322a12e7604c

Subscribe to this mod's changes

tsa-refactor-queue is a skill published in the GitHub repository aimasteracc/tree-sitter-analyzer (47 stars, last pushed 4d ago), licensed MIT. It adds 265 tokens to every session and 2,959 once invoked, about $0.0013 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

context7-cli

Use the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP. Activate when the user mentions "ctx7" or "context7", needs current docs for any library, wants to install/search/generate skills, or needs to set up Context7 for their AI coding agent.

upstash/context7 · 67 tokens

context7-mcp

This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.

upstash/context7 · 58 tokens

plan-ceo-review

CEO/founder-mode plan review. Rethink the problem, find the 10-star product, challenge premises, expand scope when it creates a better product. Four modes: SCOPE EXPANSION (dream big), SELECTIVE EXPANSION (hold scope + cherry-pick expansions), HOLD SCOPE (maximum rigor), SCOPE REDUCTION (strip to essentials). Use when…

GCWing/BitFun · 143 tokens

ship

Ship workflow: detect + merge base branch, run tests, review diff, bump VERSION, update CHANGELOG, commit, push, and create a PR. Use for an explicit /ship invocation or when the user requests the full ship, release, or deploy workflow. For an ordinary commit, push, or pull-request publishing request, use the built-in…

GCWing/BitFun · 88 tokens

design-review

Designer's eye QA: finds visual inconsistency, spacing issues, hierarchy problems, AI slop patterns, and slow interactions — then fixes them. Iteratively fixes issues in source code, committing each fix atomically and re-verifying with before/after screenshots. For plan-mode design review (before implementation), use…

GCWing/BitFun · 125 tokens

plan-eng-review

Eng manager-mode plan review. Lock in the execution plan — architecture, data flow, diagrams, edge cases, test coverage, performance. Walks through issues interactively with opinionated recommendations. Use when asked to "review the architecture", "engineering review", or "lock in the plan". Proactively suggest when…

GCWing/BitFun · 116 tokens