Skip to content

DOCS-1867 - Forbid Claude Code attribution on comments with a hook - #7099

Merged
kimsauce merged 8 commits into
mainfrom
DOCS-1867
Sep 10, 2026
Merged

kimsauce merged 8 commits into
mainfrom
DOCS-1867

Conversation

@kimsauce

@kimsauce kimsauce commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Purpose of this pull request

Adds a PreToolUse hook that stops Claude Code from appending its attribution marker to comments. Claude Code posts through a contributor's own GitHub and Jira account, so on a comment that marker is the only thing revealing a machine wrote it.

  • .claude/hooks/forbid-claude-attribution.sh denies any call carrying via Claude Code or Generated with Claude Code, including markdown-linked forms.
  • .claude/settings.json registers it on Bash and on the Jira and Slack comment tools.
  • AGENTS.md states the rule, and adds a note that Jira comments are stored as ADF, so a markdown @mention posts as literal text and notifies nobody.
  • .claude/hooks/forbid-claude-attribution.test.sh is a runnable test matrix for the hook.

Scope

Blocked: GitHub PR, issue, and review comments, Jira comments, Slack messages. Both inline bodies and file-supplied bodies are inspected, the latter by reading the path off the command line and checking the file (--body-file, --input, -F field=@path, quoted or not).

Not inspected: pull request descriptions, documentation content, and the Co-Authored-By commit trailer.

Testing

bash .claude/hooks/forbid-claude-attribution.test.sh

33 cases, covering both the paths that must deny and the paths that must not fire. Eleven of those exist to confirm the hook does not block legitimate work: pull request descriptions, commit trailers, doc edits, and read-only searches. Exits non-zero on failure, so it can run in CI. Also verified with live probes that the harness applies the hook.

No /docs content changed.

Select the type of change

  • Minor Changes - Typos, formatting, slight revisions
  • Update Content - Revisions, updating sections
  • New Content - New features, sections, pages, tutorials
  • Site and Tools - .clabot, version updates, maintenance, dependencies, new packages for the site (Docusaurus, Gatsby, React, etc.)

Ticket (if applicable)

https://sumologic.atlassian.net/browse/DOCS-1867

🤖 Generated with Claude Code

Add a PreToolUse hook that blocks any GitHub or Jira comment posted by Claude Code whose body is missing the "via Claude Code" attribution. Covers gh pr comment, gh issue comment, gh pr review, gh api comment calls, and the Jira addCommentToJiraIssue MCP tool.

Broaden the AGENTS.md attribution rule to name GitHub PRs and issues, not just Jira, and point to the hook as the enforcement mechanism.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kimsauce kimsauce self-assigned this Sep 3, 2026
@cla-bot cla-bot Bot added the cla-signed Contributor approved, listed in .clabot file label Sep 3, 2026
@kimsauce
kimsauce marked this pull request as draft September 3, 2026 10:52
@kimsauce kimsauce changed the title DOCS-1867 - Enforce Claude Code comment attribution with a hook DOCS-1867 - Forbid Claude Code attribution on comments with a hook Sep 9, 2026
Reverse the rule this ticket originally asked for. Claude Code posts through a
contributor's own GitHub and Jira account, so on a comment the attribution
marker was the only thing revealing that a machine wrote it, and it piled up on
teammates' pull requests under a colleague's name. Comments now carry no
attribution at all.

Rename require-claude-attribution.sh to forbid-claude-attribution.sh and invert
it: it denies a call that carries the marker rather than one that omits it.
Coverage is GitHub PR, issue and review comments, Jira comments, and Slack
messages. Pull request descriptions are not inspected, since a description is
not a comment and the harness stamps its own line into PR bodies by default.

Four things the naive inversion got wrong, all fixed here:

- Match markdown-linked variants, so "Generated with [Claude Code](...)" is
  caught and not just the bare phrase.
- Anchor the GitHub CLI guard to command position, so a command that merely
  mentions those subcommands is not blocked. Editing this rule's own
  documentation tripped the hook otherwise.
- Inspect file-supplied bodies (--body-file, --input, -F field=@path, quoted or
  not) by reading the path off the command line. A hook never receives file
  contents, and anything multi-line has to go through a file, so this was the
  common path for real review content and it was going unchecked.
- Restrict the gh api branch to writes. A read-only scan for existing
  attribution puts the marker in its own --jq filter, which self-denied.

Also document the known gaps, which fail open rather than blocking legitimate
work: a body path held in a shell variable, an unreadable path, and stdin
sources such as `--input -`.

AGENTS.md: rewrite both attribution bullets for the reversed rule, and add a
Jira comment format bullet, since Jira comments are stored as ADF and a
markdown @mention posts as literal text that notifies nobody.

Verified with 22 synthetic tool-call payloads covering the deny and must-not-fire
paths, plus live probes confirming the harness applies it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@kimsauce
kimsauce marked this pull request as ready for review September 9, 2026 04:01
kimsauce and others added 2 commits September 8, 2026 21:03
The hook had no committed test, so anyone changing it had to reconstruct the
cases by hand. This adds them as a runnable script next to the hook.

31 cases split by what they protect: attribution must never reach a comment
(inline bodies, chained commands, file-supplied bodies in every quoting form,
Jira and Slack tools), and the hook must not block legitimate work (clean
equivalents, pull request descriptions, commit trailers, doc edits, read-only
scans, stdin and unreadable paths).

Self-contained and portable. Paths resolve from the script location, fixtures
go in a mktemp directory cleaned up on exit, and it exits non-zero on failure
so it can run in CI. The marker strings are assembled at runtime so the file
does not carry a bare marker that would trip the hook when edited from a shell.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@amee-sumo amee-sumo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left inline comments on the Jira tool-name mismatch (blocking) and the related test-coverage gap (non-blocking). Full writeup in my top-level review comment.

Comment thread .claude/settings.json
Comment thread .claude/hooks/forbid-claude-attribution.sh Outdated
Comment thread .claude/hooks/forbid-claude-attribution.test.sh
Comment thread .claude/hooks/forbid-claude-attribution.test.sh
…ught

The hook and its matcher targeted the literal tool name
mcp__atlassian__addCommentToJiraIssue. Environments whose Atlassian MCP
server uses a different prefix (e.g. mcp__claude_ai_Atlassian_Rovo__) were
never matched, so attribution slipped through silently. Match on the
addCommentToJiraIssue suffix instead, consistent with the Slack entries.
Adds prefixed deny/allow test cases to lock this in.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@kimsauce
kimsauce requested a review from amee-sumo September 10, 2026 07:57
@kimsauce
kimsauce enabled auto-merge September 10, 2026 20:01
@kimsauce
kimsauce added this pull request to the merge queue Sep 10, 2026
Merged via the queue into main with commit 5b0e3bc Sep 10, 2026
4 checks passed
@kimsauce
kimsauce deleted the DOCS-1867 branch September 10, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed Contributor approved, listed in .clabot file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants