Skip to content

feat(code-tidying): add comment-residue read-only classifier#172

Merged
kyle-sexton merged 5 commits into
mainfrom
feat/comment-residue
Jul 14, 2026
Merged

feat(code-tidying): add comment-residue read-only classifier#172
kyle-sexton merged 5 commits into
mainfrom
feat/comment-residue

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What

A new comment-residue skill in the code-tidying plugin: a read-only classifier that flags out-of-context residue in code comments and presents Tier 1/2 findings for author-applied deletion. Mirrors declutter's architecture (detect.sh + sourceable shape library + self-contained detect.test.sh), but scans code files and detects only on the comment portion of a line.

Residue shapes: history-narration ("used to… now…"), plan-reference ("Task 2 replaces the old…", "in this PR"), conversational-antecedent ("per your request") — all Tier 1; ticket-pr-residue ("see PR #45", "JIRA-123") — Tier 2. TODO(#issue) is the sanctioned back-reference and is never flagged.

Bumps code-tidying 0.2.0 → 0.3.0; documents the skill in the manifest + README catalog.

Why

Agents leak the producing conversation/plan/history into comments — text that only makes sense inside the chat thread that wrote it. No existing skill targets this: declutter is markdown-only, compress excludes code comments, and tidy's Beck-#15 handles generic restatement, not the out-of-context residue class. This is the clean-up-afterward companion to the source-side comment rule (a separate dotfiles-repo change).

Design notes

  • Comment-scoped detection — residue-shaped words in identifiers or string literals (previously = load_cache(), # encode as UTF-8 / SHA-256) are not flagged; only the comment text is classified. This keeps false positives low; anything uncertain lands in Tier 2 (review), and the skill is read-only so the author confirms every deletion.
  • Placement — filed under code-tidying (subject = code) per the plan. It's a read-only classifier like declutter (which lives in docs-hygiene), so a mode-based argument for docs-hygiene exists; flagging for reviewer preference.

Security review (plugin-acceptance)

Touches only surface 1 — a read-only, advisory detect.sh (spawns git/find/awk, never mutates, no network, no MCP server, no userConfig/secrets, reads only files under the invoking repo via ${CLAUDE_PLUGIN_ROOT} / git rev-parse). No surface 2/5/6 trust decision required.

Test plan

  • detect.test.sh — 19/19 (shapes, tiers, opt-out, markdown-skip, dir + paths-file, and the false-positive guards: code identifier, UTF-8/SHA-256, sanctioned TODO(#123))
  • shellcheck clean
  • shfmt clean (editorconfig-aware)
  • markdownlint-cli2 clean (repo config)
  • claude plugin validate --strict . passed

🤖 Generated with Claude Code


Note

Low Risk
Read-only local bash/git scanning with no mutations, secrets, or network; CI change is a targeted hygiene exclude for test/detector content.

Overview
Adds /code-tidying:comment-residue, a read-only skill that audits code comments for four residue shapes (history narration, plan/session refs, conversational antecedents, ticket/PR back-refs) and reports Tier 1/2 findings with treatment guidance—authors apply deletions; no edits from the skill.

Implementation follows the declutter-style split: detect.sh (targets, git default, deterministic output), lib/comment-shapes.sh (comment-only extraction with string-aware leaders, shape regexes, sanctioned TODO(#issue), comment-residue-ignore), plus detect.test.sh, eval fixtures, and evals.json. code-tidying bumps to 0.3.0; README and manifest copy describe comment hygiene alongside tidy / batch-simplify.

CI comment-hygiene now excludes comment-residue scripts and evals so intentional TODO/PR-shaped test corpus and detector patterns do not trip the repo ban policy.

Reviewed by Cursor Bugbot for commit 43f7bfa. Bugbot is set up for automated code reviews on this repo. Configure here.

Add a comment-residue skill that classifies code comments for four
out-of-context residue shapes — history-narration, plan-reference,
conversational-antecedent (Tier 1), and ticket-pr-residue (Tier 2) —
emitting per-file tier findings for author-applied deletion. It mirrors
declutter's read-only classifier architecture (detect.sh + a sourceable
shape library + self-contained tests), but scans code files instead of
markdown and runs detection only on the comment portion of a line, so
residue-shaped words in identifiers or string literals are not flagged.
TODO(#issue) is the sanctioned back-reference and is never flagged.

Bump code-tidying to 0.3.0 and document the skill in the plugin manifest
and README catalog.

Security review (plugin-acceptance): touches only surface 1 — a
read-only, advisory detect.sh that spawns git/find/awk, never mutates,
never networks, ships no MCP server, declares no userConfig or secrets,
and reads only files under the invoking repo via ${CLAUDE_PLUGIN_ROOT} /
git rev-parse. No surface 2/5/6 trust decision required. Validated:
shellcheck, shfmt, markdownlint, detect.test.sh (19/19), and
claude plugin validate --strict.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rC4MXTWrQZJXG7GRtsX4K
@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9b3bb7c1-3033-4782-a8ef-6442e8ef60cc)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: medium. Not approving: Cursor Bugbot completed with status skipping (usage limit reached) and did not produce a clean review. Human review is needed before merge; no reviewers were assigned because no suitable non-author reviewers were identifiable from repo history.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6059a89395

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/code-tidying/skills/comment-residue/scripts/lib/comment-shapes.sh Outdated
The comment-residue skill is itself a code-comment linter: its detector
fixtures and shape library must contain the markers the org
comment-hygiene policy bans (TODO/FIXME and PR/issue references) — as
test corpus and as the documented TODO(#issue) sanctioned exemption.
Exempt that skill's scripts and evals via the action's exclude pathspec.
Reproduced the 7 violations locally and confirmed the exclude clears
them; the skill's SKILL.md is markdown, already outside the scan's
extension set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019rC4MXTWrQZJXG7GRtsX4K
@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_5709e73e-407c-49ab-ac73-5fbe3fc169fd)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: medium. Not approving: Cursor Bugbot completed with status skipping (usage limit reached) and did not produce a clean review. Human review is needed before merge; no reviewers were assigned because no suitable non-author reviewers were identifiable from repo history.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 142cda8cca

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/code-tidying/skills/comment-residue/scripts/detect.sh
Comment thread plugins/code-tidying/skills/comment-residue/scripts/lib/comment-shapes.sh Outdated
…ings

Address three chatgpt-codex-connector review findings on the
comment-residue classifier:

- Comment-scoped detection (comment-shapes.sh): cr_comment_text now scans
  the line as a mini-lexer that tracks "...", '...', and `...` spans and
  only treats a leader (//, /*, #, --) as a comment start when it is
  OUTSIDE a string. A residue-shaped phrase inside a URL or string
  literal (e.g. "https://x/used to do X; now does Y") is no longer
  mis-read as history-narration, honoring the skill's comment-scoped
  contract. Apostrophes in comment prose ("it's no longer used") are not
  treated as strings because the leader is found first, so genuine
  residue is still flagged. Replaces the prior "approximate, harmless"
  extractor whose stale rationale the counterexample disproved.

- ticket-pr-residue (comment-shapes.sh): the branch now also matches the
  bare hyphenated tracker key form the docs advertise (JIRA-123), not
  only "<tracker> <num>". Scoped to the enumerated tracker vocabulary
  (ticket|issue|jira|linear) so UTF-8 / SHA-256 stay unflagged.

- --paths-file guard (detect.sh): reject a missing value with exit 2.
  Previously an omitted value left one positional, `shift 2` failed
  under `set +e`, and the arg loop spun forever; a typo could hang the
  skill invocation.

Add fixtures covering all three (string-aware extraction, bare JIRA-123,
missing-value guard). detect.test.sh 24/24, shellcheck and shfmt clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gKgRoW8zkFadbE2hE4r4b
@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_76494f1e-e1fc-441e-87d9-02d8f60ccd92)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: medium. Not approving: Cursor Bugbot completed with status skipping (usage limit reached) and did not produce a clean review. Human review is needed before merge; no reviewers were assigned because no suitable non-author reviewers were identifiable from repo history.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3c627c5bcb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_9de094a9-aa63-4273-9666-4d3269308d5d)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cb8e021f0a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread plugins/code-tidying/skills/comment-residue/scripts/detect.sh

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Risk: medium. Not approving: Cursor Bugbot completed with status skipping (usage limit reached) and did not produce a clean review. Human review is needed before merge; no reviewers were assigned because no suitable non-author reviewers were identifiable from repo history.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

detect.sh cd's to the repo root before resolving caller-supplied paths, so
an explicit relative target or --paths-file value given from a subdirectory
(e.g. `detect.sh rel.py` run from `src/`) resolved against the repo root and
silently reported files=0. Capture the invocation cwd and anchor explicit
positional targets, the --paths-file path, and its relative line entries to
it before the cd; git-status discovery stays repo-relative by design.

Add regression coverage: relative target and relative --paths-file invoked
from a repo subdirectory. detect.test.sh 27/27, shellcheck clean.

Addresses the remaining chatgpt-codex-connector finding on detect.sh.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013gKgRoW8zkFadbE2hE4r4b
@cursor

cursor Bot commented Jul 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_747359e8-be44-4eda-a9b2-cb2505721cee)

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: medium. Not approving: Cursor Bugbot completed with status skipping (usage limit reached) and did not produce a clean review. Human review is needed before merge; no reviewers were assigned because no suitable non-author reviewers were identifiable from repo history.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 43f7bfa854

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kyle-sexton
kyle-sexton merged commit b3cd04c into main Jul 14, 2026
18 of 19 checks passed
@kyle-sexton
kyle-sexton deleted the feat/comment-residue branch July 14, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant