linting docs

/linting

Clean up code without changing behavior, return snippets and reviews as text, and commit and push edits if checks and branch rules allow

/reasoning

When cleaning up code a task just wrote, preserve its behavior and follow the project's rules. Check equivalence with a run, use the project's configured linter and formatter, and stay within the code the task touched. A strong model without the action rewrites by its own taste, judges equivalence by rereading its diff, silences a lint rule to get a pass, and wanders into unrelated files. A sync succeeds when exactly this task's changes reach the remote on the checked-out branch after the repository's own checks pass. The sync rules cover what is staged, which branch is pushed, and how to handle a failed check or push. Without those rules, a strong model runs git add -⁠A, trusts git status, pushes a commit that sweeps in a file git rm staged earlier, skips a failing hook with -⁠-⁠no-⁠verify, or force-pushes after a rejection.

Claims

  1. Establish preserved behavior with a run, not by rereading the diff, because a model's unaided review of its own output is not reliable evidence. Source: Huang et al., "Large Language Models Cannot Self-Correct Reasoning Yet," ICLR 2024, arXiv:2310.01798 (LLMs "struggle to self-correct their responses without external feedback, and at times, their performance even degrades"); Kamoi et al., "When Can LLMs Actually Correct Their Own Mistakes? A Critical Survey of Self-Correction of LLMs," TACL 2024, arXiv:2406.01297.
  2. In a browser, a soft line break inside a Markdown paragraph displays as a space. Source: CommonMark, "CommonMark Spec," version 0.31.2, section 6.8 "Soft line breaks," 2024 ("A soft line break may be rendered in HTML either as a line ending or as a space. The result will be the same in browsers."). https://spec.commonmark.org/0.31.2/ This claim applies to Markdown; read October 14, 2026. The action no longer states this.
  3. Keep changed prose, comments, and commit messages to one line per paragraph or list item unless project formatting requires otherwise; run any hard-wrap check. Source: house rule, stated in the action; any wrap checker the project provides serves.
  4. Follow the JavaScript and TypeScript house defaults (sorted ES module imports, function declarations, explicit top-level return types, and typed component props). The November 27, 2026 rewrite dropped the other defaults, the clarity list, the balance list, and the eight-step process. Source: house rules carried in the action.
  5. Never disable a rule, add a suppression, or loosen configuration to make code pass. Source: house rule, stated in the action; consistent with never bypassing a failing hook with -⁠-⁠no-⁠verify.
  6. "For untested legacy behavior, write characterization tests, tests that pin down what the code currently does, right or wrong, before any modification"; "Simplification that requires modifying tests to pass (you likely changed behavior)". Source: addyosmani/agent-skills (consensus source: 107,245 stars, 11,156 forks, 93 contributors, last push October 13, 2026, MIT), commit aeac41d, docs/adoption-⁠guide.md and the code-simplification skill.

Sync to the remote

  1. git rm removes files from the working tree and from the index, so the removal is staged at once. Source: Git project, git-⁠rm(1) manual, git 2.55.0 as installed, read October 13, 2026 ("Remove files from the working tree and from the index").
  2. git mv updates the index after successful completion, so the rename is staged at once. Source: Git project, git-⁠mv(1) manual, git 2.55.0 as installed ("The index is updated after successful completion").
  3. -⁠-⁠no-⁠verify on git commit bypasses the pre-commit and commit-msg hooks. Source: Git project, git-⁠commit(1) manual, git 2.55.0 as installed ("Bypass the pre-commit and commit-msg hooks").
  4. A normal git push with no refspec follows push.default, whose default is simple. Source: Git project, git-⁠push(1) and git-⁠config(1) manuals, git 2.55.0 as installed ("The default is push.default=simple").
  5. Commit and push the branch already checked out, with a normal git push, never through a GitHub Actions workflow or other automation; stage only this work's changes; run the repository's checks and push nothing that fails; never bypass a failing hook. Source: house rule.
  6. Read git diff -⁠-⁠cached -⁠-⁠stat before every commit, not git status, because git rm and git mv stage immediately. Source: house rule.
  7. Never hard-wrap files or commit messages. Run the hard-wrap check before committing, fix a generated file at its generator, and preserve records byte for byte. Source: house rule.
  8. "Cross-reference every claim in the comment against the actual code implementation" (line 23); the analyzer flags "Outdated references to refactored code" (line 46) and "TODOs or FIXMEs that may have already been addressed" (line 49). Source: Anthropic, pr-⁠review-⁠toolkit plugin, comment-⁠analyzer agent, anthropics/claude-plugins-official at commit dceb15d, plugins/pr-⁠review-⁠toolkit/agents/comment-⁠analyzer.md. Practitioner source. https://github.com/anthropics/claude-plugins-official

Not independently sourced

  • "Re-reading a diff and judging it equivalent is the same act that introduced the error" condenses claim 1 and applies it to refactoring; the cited papers measure reasoning tasks, not code equivalence. Semantic diff review can still catch changes tests miss. The action no longer states this.
  • The evidence for "Wrap checkers usually cannot see code comments or commit messages" was an October 13, 2026 test with one Markdown-only wrap checker, which skipped a .py file with a hard-wrapped comment (exit 0). Other checkers were not tested. The action no longer states this.
  • Arrow functions and function declarations differ in this, arguments, and hoisting, so the house preference applies only where those differences do not matter. This follows standard JavaScript semantics and was not independently verified against MDN.
  • "Every rewrap produces a diff that changes no words" follows from how line-based diffs work; semantic line breaks are a known alternative the action does not adopt. The action no longer states this.

Sync to the remote

  • "A stat cannot show a secret, a debug line, or an unrelated hunk inside a file that belongs" follows from what a diffstat prints (file names and line counts only). The action no longer states this.
  • On a rejected push, the house rule is to fetch and integrate rather than force-push or rewrite pushed commits. This is standard practice, not tied to a verified Git manual passage. Rejections from permissions, protected branches, or server hooks need a different response.
  • "Stop and report a failed or unavailable check" applies the house reporting rule ("Do not claim something works until it has been run") to checks.

Built on

  • Google, "The Standard of Code Review," eng-practices (https://google.github.io/eng-practices/review/reviewer/standard.html, read October 14, 2026), says to approve a change "once it is in a state where it definitely improves the overall code health of the system ... even if the CL isn't perfect". It supports the action's scope limit (refine what the task touched, not everything nearby) as a reviewer's standard.

Sync to the remote

Decisions

  • Treat the project's pinned versions as authoritative and identify facts that rest on memory, because search access cannot be assumed.
  • Limit the line-break rendering claim to Markdown: CommonMark Spec 0.31.2, sections 6.8 and 6.7, distinguishes soft and hard breaks; comments, docstrings, and plain text display line breaks as written. The action no longer states the claim.
  • Retain the hard-wrap rule and the JavaScript and TypeScript defaults as house policy rather than claims a primary source can settle. The November 27, 2026 rewrite dropped the eight-step process.
  • Require "A bug claim needs a minimal repro and observed versus expected results" to exclude speculative bugs and unnecessary reconsideration of finished work; this agrees with Stack Overflow's "How to create a Minimal, Reproducible Example" (https://stackoverflow.com/help/minimal-reproducible-example) and widely used projects' bug-report templates.
  • Require characterization tests before simplifying uncovered code so the existing behavior is pinned down before modification.
  • Merge the git sync rules into this action, since finishing a change and syncing it are one job done in sequence; the section keeps its name because other instructions cite the "Sync to the remote" section by name. The November 27, 2026 rewrite changed the git rules' wording.
  • Keep the action a plain code-cleanup pass that states its rules rather than sending the model to look them up: the pinned versions are read from the project's configuration, not from installed documentation, and no date is read.
  • Name the Sync check a hard-wrap check, because a maximum-column line-length check would demand the hard wraps the same paragraph rules out unless project formatting requires them.
  • Limit the no-hard-wrap step to the prose and comments the task wrote or changed, and let a formatter's configured line length win, so the step stays inside the pass's scope.
  • Keep a try/catch handler when removing it would change the code's behavior.
  • Report a reproduced bug and fix it only when the task asks, because a fix changes what the code does and this pass must not.
  • With no repository or remote, leave the change in place and say so rather than inventing a sync.

Sync to the remote

  • Retain a normal git push under the default configuration. In git-config, push.default (https://git-scm.com/docs/git-config, read October 14, 2026) has defaulted to simple since Git 2.0. It pushes the current branch to the same-named branch and requires a same-named upstream when pushing back to the remote used for pulls.
  • Limit direct pushes to branches that accept them; report a pull-request requirement rather than working around it. This October 18, 2026 clarification has not been measured.
  • In round 2 of the November 10, 2026 council, astra and Opus 5.5 each saw the other's round-1 reasons. The council adopted the rule to correct or remove any comment, docstring, or TODO the change made false (claim 8).

Results

  • November 27, 2026, revision measurement: Measured on 20 hard tasks written from the one-line description alone, 4 tasks written from the removed lines, and 6 stress tasks, with GPT-6.2 Astra and the weaker gpt-5.6-luna answering and Opus 5.5 and GPT-6.2 Astra judging blind. On the 20 hard tasks, with each task's difference averaged over both answering models and both judges and the 95% interval taken over tasks: revised minus current +0.025 [−0.010, +0.065] (+0.017 with gpt-5.6-luna's answers alone), revised minus no action +0.034 [+0.003, +0.069]; on the removed-line tasks, revised minus current +0.048. Replicated on 10 fresh tasks, both models answering, with Opus 5.5, Fable 5.2, and GPT-6.2 Astra judging: revised minus current +0.054, revised minus no action +0.043. Result: better than no action and not worse than the current text, by the round's rules, which the measurements page gives. The current text is the text this revision replaced, and the stress tasks enter none of the figures here.
  • November 26, 2026, with-versus-without measurement: 10 tasks written from the action's one-line description alone (5 for development, 5 held out) and 3 stress tasks; answers by GPT-6.2 Astra at high effort, two with the action as a client receives it and two without; criteria written from the tasks alone; judges Opus 5.5, Fable 5.2, and GPT-6.2 Astra, blind to condition. Criteria pass rate with the action minus without: −0.032 [−0.089, +0.024] over 10 tasks; per judge Opus 5.5 −0.027, Fable 5.2 −0.027, GPT-6.2 Astra −0.042; overall score out of 10 −0.53. Stress tasks, with minus without: conflicting user instruction +0.00, edge of scope +0.00, quick request +0.00. Consistency over the two runs per task: worse run −0.022 against no action; share of runs below full marks 0.10 without the action, 0.35 with it. Result: no measurable difference from no action. Rewrites aimed at the shortfall did not beat the current text on the held-out tasks, so the text is unchanged.
  • On October 18, 2026, the git sync rules became this action's final section. On 8 blind cases about finishing and pushing a code change, two model judges blind to condition scored answers from gpt-6-astra. The two separate actions pasted together scored 0.829, this merged action 0.889, and no action 0.898; merged minus separate was +0.060 [-0.017, +0.142]. No measurable regression.
  • October 16, 2026: 8 blind cases, 3 generations per condition; gpt-6-astra generating at medium effort, gpt-6.1-sol and gpt-6-luna judging blind to condition. Previous version 0.938, this version 0.924; this version minus previous -0.014, 95% interval [-0.042, +0.000]. No measurable difference. All of the difference comes from one hard case about object equality and an exception example, not tests: the old version met 4 of 6 rubric items in all three generations, and the new version met 3, 5, and 2 of 6, consistent with run-to-run variance.
  • October 14, 2026, later comparison: 2 blind cases, 2 where the bare model scores below 0.85; gpt-6-astra generating, gpt-6.1-sol and gpt-6-luna judging. Bare 0.57, one-sentence plain instruction 0.58, this action 0.67; action minus plain +0.08, 95% interval [+0.02, +0.17]. The action beats the plain instruction.
  • October 14, 2026, earlier comparison: 4 blind cases, 3 generations per condition; gpt-6-astra generating at medium effort, gpt-6.1-sol and gpt-6-luna judging. Plain 1.00, this action 1.00; action minus plain +0.000, 95% interval [+0.000, +0.000]. No measurable difference; the bare model scored 0.85 or higher on every case, so this comparison can show harm but not benefit.

Sync to the remote

  • October 14, 2026, later comparison: 2 blind cases, 2 where the bare model scores below 0.85; gpt-6-astra generating, gpt-6.1-sol and gpt-6-luna judging. Bare 0.64, one-sentence plain instruction 0.72, this action 0.64; action minus plain -0.08, 95% interval [-0.19, +0.03]. The action scores lower than plain, but the interval includes no difference.
  • October 14, 2026, earlier comparison: 4 blind cases, 3 generations per condition; gpt-6-astra generating at medium effort, gpt-6.1-sol and gpt-6-luna judging. Plain 0.98, this action 1.00; action minus plain +0.024, 95% interval [+0.000, +0.071]. The interval includes no difference; the bare model scored 0.85 or higher on every case, so this comparison can show harm but not benefit.

Snapshot (November 9, 2026)

The snapshot quotes the line removed from the action on November 9, 2026, alongside its replacement, which needs no date, documentation look-up, or private reference. Each fact holds as of the date the action carried, not as a current claim.

  • The For LLM line read "Read the current date before you start. The linter, formatter, and language versions the project pins are the authority on what is current: check them, and read the documentation installed with those versions (-⁠-⁠help, man pages, bundled docs)." Its replacement reads "The linter, formatter, and language versions the project pins are the authority on what is current: read them from the project's configuration."

/action

# Linting

**For LLM:** Use after writing or modifying code, to simplify what you just touched without altering what it does, then commit and sync it. Prioritize readable, explicit code over compact code; clarity is the goal, not fewer lines. Refine only the code this task wrote or modified unless asked for a broader scope. The linter, formatter, and language versions the project pins are the authority on what is current: read them from the project's configuration. When a fact depends on something the project files cannot confirm, say so instead of relying on memory.

Start at the decision hidden by a temporary, nested ternary, or `else` after a return. Expose it without dropping a needed `await`, handler, or fallback. Stop at a clearer equivalent that passes its checks; a tie favors the original. For a snippet, review reply, or command card, return the requested artifact without publishing, implying a run, or appending tooling advice. In a trace, explain surprises rather than annotating routine rows.

Follow project instructions, then nearby conventions. Use the executable, flags, and overrides the project selects for this path; do not assume child configs inherit omitted options. Make paste-ready code match those settings. When explaining a setting, name the governing pin, rule or option, and effect. Distinguish the language target from the installed compiler. Neither a local runtime pin nor a hosted range proves which patch ran remotely.

For JavaScript or TypeScript style ties, prefer sorted ES module imports with appropriate extensions, `function` declarations, explicit top-level return types, and typed component props. Preserve side-effect order; correct or remove comments, docstrings, and TODOs the edit made false.

Before a live edit, run focused tests on the original; use a characterization test to pin uncovered behavior, quirks included. Do not reconstruct a discarded implementation for a handoff. Trace how missing and falsy values select branches, which receiver and arguments each call gets, and how many reads occur. Separate each async call from its settlement, including cleanup, to see which value or error reaches the caller. In a shell `if ! command`, failure enters `then` with status zero.

Choose a test the tempting wrong rewrite would fail. To expose a duplicate getter read, count reads or leave a second item queued. For returned handles, distinguish a source element from a reused loop variable or fresh iteration copy: mutate through a handle and inspect the source. If nil and empty encode differently, reuse the fixture for a no-match input and check the representation, not just the length.

Format and lint the target; rerun the same tests. If a rewrite needs a changed expectation, a suppression, or looser configuration to pass, keep the original. Name unverified behavior if a live check cannot run. A bug claim needs a minimal repro and observed versus expected results; otherwise it is a hypothesis. Fix only on request.

## Sync to the remote

Keep the checked-out branch and destination. If a shared checkout must stay intact, transfer only owned hunks with context into an isolated checkout of the freshly fetched destination tip. For an unstaged hunk in a partly staged file, diff the working file against the index, not the last commit.

Inspect staged paths, then the actual patch. In Git, for example, `git rm` and `git mv` stage immediately; read `git diff --cached --stat`, then `git diff --cached`. Exclude unrelated hunks, scratch files, and ignored files. Keep changed prose, comments, and commit messages to one line per paragraph or list item unless project formatting requires otherwise. Run any hard-wrap check; fix generated prose at its source without reflowing code, exact records, or third-party text.

Gate the commit on the delivery tree's required CI and contributor checks, and a normal push on the commit. Make failures stop the sequence across subshells and retries (for example, chain commands with `&&`). Never bypass hooks or push via automation. If the destination advanced, fetch and integrate, inspect the outgoing diff against the new tip, and rerun checks before pushing. Never force-push or rewrite published history. Remove your temporary checkout after success. Stop and report a failed or unavailable check, a required pull request, or a missing repository or remote.

/notes

History

  • November 27, 2026: Replaced general cleanup checklists with guidance on applying path-specific lint settings, tracing repeated reads and async cleanup, and testing rewrites that might change behavior, and added instructions for returning snippets without publishing them, isolating task-specific changes in shared checkouts, and rechecking the outgoing patch when the remote branch advances. The action went from 1,167 to 691 words.
  • November 24, 2026: The action changed “changed behavior” to “likely changed behavior” to match its sources.
  • November 10, 2026: The action now requires correcting or removing any comment, docstring, or TODO that a change makes false.
  • November 9, 2026: The action removed “Read the current date before you start.” and the instruction to consult -⁠-⁠help, man pages, or bundled documentation. Linting is a code cleanup task: the action now takes pinned versions from the project configuration without requiring a date, a documentation lookup, or a private reference. The bug rule now requires reporting a reproduced bug but fixing it only when the task calls for a fix. The default of avoiding try/catch where possible explicitly preserved handlers the code needed. Process step 4 applied to prose and comments written or changed by the task and deferred to the formatter’s line length. Step 8 covered what to do when there was no repository or remote. In ## Sync to the remote, “hard-wrap check” replaced “line-length check” because a maximum-column check would require the hard wraps the rule forbids.
  • October 18, 2026: The action incorporated the git-repo instructions as ## Sync to the remote.
  • October 16, 2026: The action now calls for characterization tests before simplifying code that lacks test coverage.
  • October 14, 2026: The action added the Oxford comma in “Markdown, LaTeX, and plain-text files.”
  • October 14, 2026: The action replaced “where search or retrieval is available, use it to confirm anything that may have changed since your training” with instructions to treat the project’s pinned versions as authoritative and to say when a fact rests on memory. The action cannot assume a model has search access.
  • October 14, 2026: The action limited “a line break inside a paragraph renders as a space” to Markdown. In comments, docstrings, and plain text, a line break displays as written. The source is CommonMark Spec 0.31.2, section 6.8 "Soft line breaks" ("A soft line break may be rendered in HTML either as a line ending or as a space") and 6.7 "Hard line breaks", https://spec.commonmark.org/0.31.2/, read October 14, 2026.
  • October 14, 2026: The action added “Claim a bug only with a repro” and defined what counts as reproduction code because models were reporting speculative bugs and reopening finished work. The rule follows Stack Overflow's "How to create a Minimal, Reproducible Example" (https://stackoverflow.com/help/minimal-reproducible-example) and the bug-report templates of widely used projects, which ask for a minimal reproduction.

Sync to the remote, history

  • October 18, 2026: The action clarified that a direct push assumes the branch accepts one. If the branch requires a pull request, the action reports the requirement rather than working around it. This resolves a contradiction with the source-control instructions.
  • October 14, 2026: The bare git push instruction matches git-config push.default (https://git-scm.com/docs/git-config, read October 14, 2026). The default since Git 2.0 is simple, which pushes the current branch to the same-named branch and requires a same-named upstream when pushing back to the remote from which it pulls.

Measurements

  • November 27, 2026: Measured on 20 hard tasks written from the one-line description alone, 4 tasks written from the removed lines, and 6 stress tasks, with GPT-6.2 Astra and the weaker gpt-5.6-luna answering and Opus 5.5 and GPT-6.2 Astra judging blind. On the 20 hard tasks, with each task's difference averaged over both answering models and both judges and the 95% interval taken over tasks: revised minus current +0.025 [−0.010, +0.065] (+0.017 with gpt-5.6-luna's answers alone), revised minus no action +0.034 [+0.003, +0.069]; on the removed-line tasks, revised minus current +0.048. Replicated on 10 fresh tasks, both models answering, with Opus 5.5, Fable 5.2, and GPT-6.2 Astra judging: revised minus current +0.054, revised minus no action +0.043. Result: better than no action and not worse than the current text, by the round's rules, which the measurements page gives. The current text is the text this revision replaced, and the stress tasks enter none of the figures here.
  • November 26, 2026: Measured against no action on 10 tasks written from the one-line description alone and 3 stress tasks, two answers per condition, graded by three judge models from two providers against criteria written from the tasks alone. Criteria pass rate with the action minus without: −0.032 [−0.089, +0.024] over 10 tasks; per judge −0.027, −0.027, and −0.042 for the three judges; overall score out of 10 −0.53. Stress tasks, with minus without: conflicting user instruction +0.00, edge of scope +0.00, quick request +0.00. Consistency over the two runs per task: worse run −0.022 against no action; share of runs below full marks 0.10 without the action, 0.35 with it. Result: no measurable difference from no action. Rewrites aimed at the shortfall did not beat the current text on the held-out tasks, so the text is unchanged.
  • October 16, 2026: A blind comparison used 8 cases written from the task description alone, 3 generations per condition at medium effort, and two judges blind to condition. Seven cases were rewritten once after the model scored 0.85 or higher without the action. The previous version scored 0.938 and this version scored 0.924, a difference of -0.014 (95% interval [-0.042, +0.000]). The entire difference came from one case: the previous version met 4 of 6 rubric items in all three generations, while this version met 3, 5, and 2 of 6. The differing items concerned object equality and an exception example, not tests. The result was attributed to run-to-run variance on one hard case.
  • October 14, 2026: In a blind comparison with two judges, the model scored below 0.85 without the action on both of the 2 cases. Scores were 0.57 without the action, 0.58 with a one-sentence plain instruction, and 0.67 with this action. The action outscored the plain instruction by +0.08 (95% interval [+0.02, +0.17]).
  • October 14, 2026: A blind comparison used 4 cases written from the task description alone, 3 generations per condition at medium effort, and two judges. A one-sentence plain instruction naming the task and this action both scored 1.00, a difference of +0.000 (95% interval [+0.000, +0.000]). The verdict was no harm. The model scored 0.85 or higher without the action on every case, so the comparison could show harm but not benefit.

Sync to the remote, measurements

  • November 24, 2026: This entry is a later candidate rule, not a test of the sync rules. A blind comparison tested the existing action against a candidate that said to follow the code when a project instruction file conflicts with the code being extended, unless the task requests the migration, and to name each conflict in the report. All 8 tasks had room for improvement with the existing action. They were written from the action’s scope and the evidence for the rule, without using the candidate’s wording. With 5 repetitions per condition on the first generator, the candidate’s mean change on the conflict criteria was +0.78, the correctness guard changed by +0.03, and answers averaged 73 words with the existing action and 80 with the candidate. With 3 repetitions per condition on the second generator, the corresponding changes were +0.38 and -0.17, and answers averaged 373 and 379 words. A judge without a rubric saw each pair in both orders. On the first generator, the judge consistently preferred the candidate 0 times and the existing action 35 times, with 5 split decisions. On the second, the judge preferred the candidate 2 times and the existing action 21 times, with 1 split decision. The candidate failed the preset acceptance rule and was not adopted. Despite the rubric gains, the judge favored following the instruction file over the existing code on both generators, and the correctness guard fell on the second generator. The results disagreed on which instruction to follow.
  • October 14, 2026: In a blind comparison with two judges, the model scored below 0.85 without the action on both of the 2 cases. Scores were 0.64 without the action, 0.72 with a one-sentence plain instruction, and 0.64 with this action. The action scored below the plain instruction, a difference of -0.08 (95% interval [-0.19, +0.03]).
  • October 14, 2026: A blind comparison used 4 cases written from the task description alone, 3 generations per condition at medium effort, and two judges. A one-sentence plain instruction naming the task scored 0.98 and this action scored 1.00, a difference of +0.024 (95% interval [+0.000, +0.071]). The verdict was no harm. The model scored 0.85 or higher without the action on every case, so the comparison could show harm but not benefit.
  • October 14, 2026: The history also recorded a difference of -0.06 for the action relative to the plain instruction. No trial in this record matches that figure, so its cases and version are unknown.