基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/tomes --skill tsa-refactor-queue命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
> Use when this capability is needed.
Use when writing kernel, account, or note MASM code that reads from or writes to the advice provider (advice stack / advice map) — validate advice data.
Use when writing a Rust test that exercises a failure path or a MASM test that expects a `panic` / `assert` — assert on the specific expected error variant or error code.
| name | tsa-refactor-queue |
| description | | Use when this capability is needed. |
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.
tsa-health-watch — re-rank with churnDon't use when:
health action=file or tsa-edit-safety)tsa-graph + edit action=refactor directlygit_state=shallow makes mod_count_30d unreliableCall these in ONE message:
health action=project with min_grade: "D" and max_files: 20 — F/D files + per-file weakest_dimensionhealth action=dead with max_dead: 200 — symbol-level dead candidates, grouped by filehealth 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.
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.Sort descending, keep top 5.
For each of the top 5 files, fan out one more parallel batch:
# For each candidate file:
structure action=analyze file_path=<f> format_type="compact"
→ list of symbols + complexity + line ranges → pick worst symbol
nav action=callers function_name=<worst_symbol> include_activation=true limit=50
→ blast_radius = len(callers) where callee_resolution in {local, project}
edit action=refactor file_path=<f>
→ action_hint: split | extract | delete | rename
For each row in the top 5, produce:
- file: tree_sitter_analyzer/api.py
rank: 1
health_grade: F
health_score: 42
weakest_dimension: complexity # from health action=project
mod_count_30d: 18 # summed from activation
dead_symbols: 4 / 67 # 6.0%
target_symbol: api.analyze # worst from structure action=analyze
blast_radius: 23 # local+project callers
action: split # split → extract helpers; delete → prune dead; extract → DRY
estimated_token_savings: ~8k # rough: 0.5 * (dead_symbols * 200)
verification_command: uv run pytest tests/unit/test_api.py -q
Run on /Users/aisheng.yu/git-private/tree-sitter-analyzer:
# Parallel CLI batch (humans):
uv run tree-sitter-analyzer --project-health --max-files 20 --output-format json > /tmp/health.json
uv run tree-sitter-analyzer --dead-code --output-format json > /tmp/dead.json
uv run python -c "
import sqlite3
sql = '''
SELECT s.file_path, SUM(a.mod_count_30d) AS churn
FROM ast_symbol_activation a
JOIN ast_symbol_rows s ON s.id = a.symbol_id
GROUP BY s.file_path ORDER BY churn DESC LIMIT 50'''
for r in sqlite3.connect('.ast-cache/index.db').execute(sql):
print(*r, sep='\t')
" > /tmp/churn.tsv
Expected shape after joining (truncated, illustrative — actual numbers vary
with the working tree state — last fixture run on feat/consolidated produced
something like this for the top three rows):
top_5_refactor_queue:
- rank: 1
file: tree_sitter_analyzer/api.py
health_grade: F
weakest_dimension: complexity
mod_count_30d: 18
dead_symbols: 3
target_symbol: api.analyze
blast_radius: 23
action: split
note: "called from CLI + MCP + tests — split into api_facade + api_core first"
- rank: 2
file: tree_sitter_analyzer/languages/python_plugin.py
health_grade: F
weakest_dimension: size
mod_count_30d: 11
dead_symbols: 7
target_symbol: PythonElementExtractor.extract
blast_radius: 6
action: extract
note: "650+ lines — gap report calls out Language Plugin extractors specifically"
- rank: 3
file: tree_sitter_analyzer/mcp/server.py
health_grade: D
weakest_dimension: dependencies
Read the queue right:
test_python_detects_deep_nesting. Run that test before/after.BaseMCPTool adjacency — solo commit, macOS gate
check (see CLAUDE.md design-decision §2).The action column should drive how you ticket the refactor:
| action | when to pick | typical PR shape |
|---|---|---|
| split | weakest_dimension ∈ {size, complexity} and blast_radius >= 5 | extract helpers, no public-API change |
| extract | weakest_dimension = duplication or repeated patterns across files | new shared util module |
| delete | dead_symbols / total_symbols > 15% and weakest_dimension != git_hotspot | pure prune PR |
| rename | only if edit action=refactor returns rename_advised: true AND blast_radius < 10 | tiny solo PR |
If two actions tie, prefer delete first — it's the cheapest, lowest-risk PR
and shrinks the next queue automatically.
tsa-edit-safety
before editing — the queue is prioritization, not a green light.BaseMCPTool,
PathResolver, or SecurityValidator (CLAUDE.md "Foundational changes")
— solo commits only.mod_count_30d column when git_state=shallow (CI). The
CLI returns git_state per symbol — bail out of churn ranking and fall
back to health-only ranking if any row in the top 20 is shallow..md files to the source set hoping for markdown smells — see
CLAUDE.md design-decision §4. Build a separate markdown_health tool instead.# 1. Health portrait (defaults to D-and-worse)
uv run tree-sitter-analyzer --project-health --max-files 20 --output-format json
# 2. Dead-code candidates
uv run tree-sitter-analyzer --dead-code --output-format json
# 3. Complexity heatmap (covers the structural smell axis)
uv run tree-sitter-analyzer --overview --output-format json
# 4. Per-file churn (no dedicated --temporal flag yet — query DB directly)
uv run python -c "
import sqlite3
sql = '''
SELECT s.file_path, SUM(a.mod_count_30d) AS churn_30d
FROM ast_symbol_activation a
JOIN ast_symbol_rows s ON s.id = a.symbol_id
WHERE a.git_state = 'tracked'
GROUP BY s.file_path
ORDER BY churn_30d DESC LIMIT 50'''
for r in sqlite3.connect('.ast-cache/index.db').execute(sql):
print(*r, sep='\t')
"
# 5. Per-row enrichment (loop top 5)
uv run tree-sitter-analyzer <file> --table --output-format json
uv run tree-sitter-analyzer --callers <SYMBOL> --output-format json
uv run tree-sitter-analyzer <file> --refactor --output-format json
The MCP-side ranking script (PRIORITY × log(churn+1) × dead_ratio) is deterministic — implement it as a small Python helper if you run the CLI flow repeatedly. Don't ask an LLM to do arithmetic over 20 rows.
verdict: INFO # this skill is observational + prioritization, not a gate
queue_at: <iso-8601 timestamp>
queue_size: 5
top_5:
- rank: 1..5
file: <abs path>
health_grade: A | B | C | D | F
health_score: 0-100
weakest_dimension: complexity | structure | dependencies | duplication | size | git_hotspot
mod_count_30d: <int> # 0 if git_state != tracked
dead_symbols: <int>
total_symbols: <int>
target_symbol: <name>
blast_radius: <int> # local+project callers
action: split | extract
[, ]
Source: aimasteracc/tree-sitter-analyzer — distributed by TomeVault.