agentleFS
tusharsrivastavatusharsrivastava/shark-skills/skills/code-health/SKILL.md

code-health

Skill32 starsChanged 15 days agoMITView on GitHub

New security, complexity and architecture findings in your changes - how to read the code-health review that blocks your stop when you finish, fix each finding or accept it on purpose, and run the check for a diff. Use with shark:code-authoring when you write or correct code in a project whose AGENTS.md has analyze rows.

15 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use dependency-watch, perform-task and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • telegramdesktopSkill

    dependency-watch

    Audit Telegram Desktop dependencies on freshly fetched origin/dev for releases and security fixes, including upstream lag and backport candidates in patched forks. Use for the scheduled dependency monitor or an explicitly requested dependency report.

    Also in 5 projects that use this

  • telegramdesktopSkill

    perform-task

    Resolve, start or resume, implement, review, test, and publish exactly one existing ai-tdesktop task by short slug or full dated id, including rare blocked retries and split-required results. Use when the user invokes $perform-task or /perform-task with a known task name, or when the continue scheduler delegates one selected task. Runs standard review lenses with fast applicability bailouts and selects task-specific domain and evidence instruments without selecting additional work.

    Also in 5 projects that use this

  • JerovinoSkill

    process-inbox

    Processes tasks.md inbox items by triaging each one to its proper location in the vault

    Also in 5 projects that use this

  • Trejon-888Skill

    continue

    Load project context, alignment audit, status check, suggest next action. Auto-invoke at session start, after context switches, or when user says 'continue', 'pick up where we left off', 'resume', 'what's next', 'status check', 'what now'.

    Also in 5 projects that use this

  • NVIDIASkill

    rebase

    Rebase the current branch onto the latest main and resolve conflicts

    Also in 5 projects that use this

  • +1 more from telegramdesktop

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 15 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat a digest like a failing test:

    line 34
  2. Very specific:

    A layer violation (arch/...) is a shared decision: Do not change the architecture rule and do not allow it.

    line 46
  3. Very specific:

    Use lizard --csv: the XML format has no end line and no parameter count.

    line 102
  4. Distinctive:

    Write your own rules (references/rule-authoring.md).

    line 103
  5. Very specific:

    Commit .shark/health-baseline.json after baseline record.

    line 105

“Common” is measured: kept by at least 6 in 10 of the 15 edited versions of this file we could read. “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

Code health

A project that opts in names its analyzers in AGENTS.md (## Commands: analyze:file, analyze:diff, arch:check, analyze:full) and its limits in ## Quality budgets. Shark runs them and shows you only what is new: a finding that is not in the committed baseline, not allowed on purpose, and not in the file at the commit where your session started. Old debt never shows. AGENTS.md wins over a rule here.

1. When you finish: the review

The shark hook health-review reviews your work when you end it, like a code reviewer. When the main session stops, or when shark:code-writer or shark:lead-engineer ends, it runs analyze:file on each source file that changed since the session started (also changes that you committed), and compares each file with its version at that commit. It prints nothing when nothing is new. When something is new, it stops you from ending and gives you a digest. You get each finding one time in a session, and at most 3 reviews block in one session. A later review checks only the files that changed since their last review; when none changed, it only runs git. In a multi-repo workspace it reviews each repository in ## Repositories, with the project file of that repository (its analyze:* commands and budgets). hook.review: off turns it off.

code-health: 2 new in src/billing/invoice.py (budget: ccn 10)
1. ERROR sec/sql-string-concat  L42  SQL text built from a value at run time ...
   Fix: use a bound parameter, for example execute("... WHERE id = ?", (value,)).
   id: 3f9c0a12b4de
2. WARN  cx/ccn  L60  `apply_discounts` ccn 9 -> 14 (budget 10).
   Fix: see complexity-playbook.md (guard clauses, extract function, table-driven rules).
   id: 8a71c3e09f42
+0 more. Not verified: none.

Treat a digest like a failing test:

  1. Fix it before you finish. An ERROR is a defect that you made. Fix the code, not the rule. The fix hint names the safe form. For complexity, use references/complexity-playbook.md.
  2. Or accept it on purpose, only when the finding is a false positive or the brief asks for this exact code:

    node "${CLAUDE_PLUGIN_ROOT:-<directory of this skill>/../..}/skills/code-health/scripts/health.mjs" baseline allow <id> --reason "<why>" [--lane <lane name>]

    A lane always gives --lane: lanes never write .shark/health-baseline.json. The lead folds lane entries into the baseline at merge, and lists each one in the merge log. "It was faster" is not a reason.

  3. A layer violation (arch/...) is a shared decision. Do not change the architecture rule and do not allow it. Return it to your caller with the import that you need and why.

A digest about a line that you did not change is still yours when your change caused it (for example, a function that crossed the complexity budget because you added a branch).

code-health: not verified (...) means that an analyzer is missing, crashed or timed out. Continue, and write "code-health: not verified" with the reason in your report. Never report the code as checked.

2. Your report, and the check by hand

The review in §1 runs by itself. Run the same check by hand only when hook.review is off, or to check a branch (for example before a merge):

node "${CLAUDE_PLUGIN_ROOT:-<directory of this skill>/../..}/skills/code-health/scripts/health.mjs" diff --base <the commit where your work started>

Exit 0: nothing new. Exit 1: the digest lists what is new; fix it or allow it as above. Exit 3: the project has no analyze row (say "code-health: not configured"). Exit 4: an analyzer failed (say "code-health: not verified"). Your report has one line: Code health: <n> new, <n> allowed (ids and reasons), not verified: <items or none>.

3. Commands

CommandDoes
health.mjs file <path> [--base <ref>]New findings of one file (what the hook runs).
health.mjs diff [--base <ref>]New findings of all changed files, plus arch:check.
health.mjs baseline recordRecords the committed baseline (.shark/health-baseline.json) from the current code.
health.mjs baseline compare [--base <ref>]New, worsened and fixed findings.
health.mjs baseline allow <id> --reason <text> [--lane <name>]Accepts one finding on purpose.
health.mjs baseline foldMoves the lane allow files into the baseline (the lead, at merge).
health.mjs sarif --out <file> [--only sec,arch,cx]Merged SARIF for CI, GitHub code scanning or SonarQube.
health.mjs rules addCopies the starter rules for the languages of the project to .shark/rules/. Keeps a rule file that exists.

Exit codes: 0 clean, 1 new findings, 2 usage error, 3 a command row is missing in AGENTS.md, 4 an analyzer crashed or timed out.

4. Set it up in a project

/shark:init does this setup and checks it (skills/init/scripts/doctor.mjs). By hand: add the rows to AGENTS.md › Commands, and run health.mjs rules add to copy the starter rules of this skill to .shark/rules/:

KeyExample (Python and TS)
analyze:fileopengrep scan --quiet --disable-version-check -f .shark/rules --sarif-output={out} {file} and lizard --csv {file}
analyze:diffnone (shark runs analyze:file on each changed file)
analyze:fullopengrep scan --quiet --disable-version-check -f .shark/rules --sarif-output={out} . and lizard --csv .
  • /shark:doctor installs Opengrep (the release binary, with its SHA-256 checked) and Lizard (hash checked) into the shark tool folder, and shark runs them from there with no PATH setup. Never install Opengrep from PyPI (a malicious package uses the name). Keep --disable-version-check. Do not use --experimental: in 1.33.1 it found nothing on the starter rules.
  • One Opengrep 1.x scan of one file takes about 2 s, mostly start-up (p95 2.2 to 2.3 s, measured 2026-11-21). Shark scans the file and its base version in parallel. The review runs one time when you finish, not after each edit: per-edit checks cost tokens and wake-ups and changed no result in the cost check (2026-11-25).
  • Use lizard --csv: the XML format has no end line and no parameter count.
  • Write your own rules (references/rule-authoring.md). Never copy rules from the Semgrep registry: their license does not allow distribution.
  • Commit .shark/health-baseline.json after baseline record. A project with no baseline still works: shark then compares each file with its content at the start of the session.

The digest format and its limits are in references/digest-format.md.

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.