agentleFS
modeled-information-formatmodeled-information-format/research-harness-template/.claude/skills/md-fix/SKILL.md

md-fix

Skill2 starsChanged 56 days agoMITArchived repositoryView on GitHub

Remediate non-compliant Markdown — fix the markdownlint classes that `markdownlint-cli2 --fix` cannot auto-resolve (MD025 frontmatter-title, MD060 tables, MD033 placeholders, MD036 bold-as-heading, MD029 list-embedded blocks), repair broken intra-repo links, and triage cSpell/typos, escalating only genuine judgment calls. Use this skill when the user wants to fix Markdown lint errors, clean up markdown, make a doc compliant, fix broken doc links, resolve markdownlint/cSpell/typos diagnostics, or remediate documentation without suppressing warnings. Triggers on 'fix markdown', 'fix lint', 'markdownlint errors', 'fix the docs', 'clean up this markdown', 'fix broken links', 'md-fix', 'remediate markdown'. Never suppresses a diagnostic.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

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

    Never suppress: Do not add markdownlint-disable / prettier-ignore comments or .md entries to .markdownlintignore / .prettierignore.

    line 22
  2. Distinctive:

    If explicit paths/globs were given, use them.

    line 48
  3. Distinctive:

    If the result is empty and no path was supplied, ask the user which path/tree to remediate.

    line 54

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

md-fix — Markdown remediation

Repairs non-compliant Markdown without suppressing diagnostics. It pairs with the project's md_guard hook (.claude/hooks/markdown/): the hook guards (denies suppression, auto-runs markdownlint-cli2 --fix on edits); this skill remediates — it fixes the residual classes --fix cannot, plus links and spell/typo false positives, and escalates only what genuinely needs judgment.

The deterministic engine is .claude/hooks/markdown/md_remediate.py (shares md_lint_core.py with the hook). This skill drives it, then resolves escalations.

Non-negotiable invariants

  • Never suppress. Do not add markdownlint-disable / prettier-ignore comments or .md entries to .markdownlintignore / .prettierignore. The md_guard PreToolUse hook denies these anyway.
  • Never disable a rule to silence a fixable issue. A markdownlint config rule-off is acceptable only as deliberate, justified project policy (the hook warns on it). Fix the Markdown instead.
  • Never blind-edit prose for spelling. Proper-noun/identifier false positives go to the allowlist (cspell.json / _typos.toml); genuine typos are reworded in context by a human or the escalation agent, never auto-replaced.

Arguments

Parse $ARGUMENTS.

ArgMeaning
<path-or-glob> ...Files/globs to remediate. Default: Markdown changed this session (git status --porcelain, .md/.markdown only). If none, ask for a path.
--checkReport only; write nothing. Exit 1 if anything would change or escalates.
--dry-runPrint unified diffs; write nothing.
--apply-allowlistAdd proper-noun spell hits to _typos.toml (write mode only).
--no-spellSkip the cSpell/typos pass.

Execution flow

1. Resolve targets

If explicit paths/globs were given, use them. Otherwise:

git -C "$CLAUDE_PROJECT_DIR" status --porcelain | awk '{print $2}' | grep -E '\.(md|markdown)$' || true

If the result is empty and no path was supplied, ask the user which path/tree to remediate.

2. Run the remediation engine

python3 "$CLAUDE_PROJECT_DIR/.claude/hooks/markdown/md_remediate.py" [FLAGS] <targets...>

Pass --check or --dry-run through when supplied. The tool prints a JSON report:

{ "mode": "...", "results": [
  { "file": "...", "changed": true, "fixed": ["MD025","MD060"],
    "links_repaired": ["old -> new"], "allowlist_candidates": ["..."],
    "escalate": [ { "class": "typo|link|spell", "detail": "..." } ],
    "residual": "<markdownlint lines that survived>" } ] }

In write mode the deterministic fixes are already applied on disk (the engine also runs markdownlint-cli2 --fix internally for the auto-fixable classes).

3. Escalate judgment cases

Collect every escalate[] item across files. If non-empty, spawn ONE agent to resolve them from context (do not resolve them by guessing yourself):

Agent(subagent_type="general-purpose"): "Resolve these Markdown remediation
escalations WITHOUT suppressing anything. For each:
 - class 'typo': read the file at the cited location, decide if it is a real
   misspelling; if so correct it in context, if it is a proper noun add it to
   <repo>/_typos.toml [default.extend-words] and <repo>/cspell.json words.
 - class 'link': find the intended target file in the repo and fix the relative
   link; if no target exists, report it (do not invent one).
 - residual markdownlint lines: fix the underlying Markdown; never add a disable
   directive or ignore-file entry.
After fixing, re-run `python3 .claude/hooks/markdown/md_remediate.py --check <files>`
and confirm zero changes and zero escalations. Return what you changed."

4. Verify clean

Re-run in check mode and confirm nothing remains:

python3 "$CLAUDE_PROJECT_DIR/.claude/hooks/markdown/md_remediate.py" --check <targets...>

Exit 0 with empty escalate[] and changed:false everywhere = compliant. Also confirm the linter directly on a representative file:

npx --yes markdownlint-cli2 <targets...>   # only MD013 (line-length, intentionally off) may remain

5. Report

Summarize per file: classes fixed, links repaired, allowlist additions, and any escalations and how they were resolved. State plainly if anything could not be fixed and why — never report "clean" while residual lint or unresolved escalations remain.

Notes

  • Idempotent: re-running on a compliant file makes no changes.
  • MD013 (line-length) is intentionally off in the project ruleset (.claude/hooks/markdown/default.markdownlint.jsonc) — long tables, commands, and URLs cannot wrap; it is not treated as debt.
  • Tests: bash .claude/hooks/markdown/test_md_remediate.sh (engine) and bash .claude/hooks/markdown/test_md_guard.sh (hook).

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.