CI Reviews That Don't Repeat Themselves: Prior Findings, Existing Tests and Test Standards in CLAUDE.md
A review bot that starts fresh on every push posts the same comment again next to the one new issue. Three runs on one pull request show how prior findings in the prompt, existing tests and CLAUDE.md standards cut the noise.
What you will learn
- Pass the previous review's findings into the prompt so only new or unaddressed issues are reported
- Post a comment only for new findings and list unaddressed ones without posting again
- Include existing test files so test suggestions skip what is already covered
- Keep testing standards and review criteria in CLAUDE.md, where Claude Code loads them in CI
Before you start
- A Claude Code review step in CI with claude -p and JSON output
- Basic pytest fixtures
You push a fix to a pull request. The review bot wakes up and posts its comments. One of them you already saw last time, and it's still talking about it. Worse, the genuinely new comment sits right next to the repeat, easy to miss.
The bot has no memory of what it said last time. We give it one, from three sources: the earlier findings, the tests you already have, and your test standards. This article assumes you already have a review job running Claude Code headless with JSON output; that setup is covered in a Claude Code review bot in CI, so here we look only at what goes into the prompt and what comes out.
Two pushes, one repeat
A developer opens a pull request on the shop app's api/orders.py and pushes twice.
- Push one gets two comments: a shipped order can be cancelled (
shipped-cancel), and an order id below one isn't checked (id-below-one). Fair enough. - Push two fixes the shipped order. But the review starts from nothing, so it posts
id-below-oneagain, next to one genuinely new comment: float math can lose a cent (float-cents).
Think of a proofreader reading your second draft. Without her old notes, she marks the same comma and the same typo all over again. Give her the notes, and she crosses off what you fixed and writes down only what's still there or new.
What goes into the review
The workflow step that runs on every push pipes a built prompt into Claude Code and saves the result for the next push:
- name: Review, with the last review in context
run: |
python ci_review.py prompt review \
--prior prior_findings.json \
--changed api/orders.py |
claude -p --output-format json \
--json-schema "$(cat findings_schema.json)" > result.json
python ci_review.py post result.json --save
The schema gives every finding a status of new or unaddressed:
"status": {"enum": ["new", "unaddressed"]},
There's no "fixed" status on purpose. A fixed finding is simply not listed.
The prompt builder
ci_review.py builds the prompt in plain Python:
"""CI helper: build the `claude -p` prompt, post only what is new."""
import argparse, json, pathlib
RULE = ("Report only issues that are new or still unaddressed. "
"Do not repeat a finding that was fixed.")
def read(path):
return pathlib.Path(path).read_text()
def block(title, text):
return f"=== {title} ===\n{text.rstrip()}\n"
def build_prompt(mode, changed, prior, tests):
parts = [f"TASK: {mode} the changed file below.\n"]
if mode == "review":
parts.append(f"RULES: {RULE}\n")
for name in changed:
parts.append(block(f"CHANGED FILE {name}", read(name)))
if prior and pathlib.Path(prior).exists():
parts.append(block("PRIOR FINDINGS", read(prior)))
for name in tests:
parts.append(block(f"EXISTING TESTS {name}", read(name)))
return "\n".join(parts)
- The rule is one sentence: report only issues that are new or still unaddressed.
- The changed file goes in first.
- The prior findings go in if the file exists. On the very first push there are none.
- Existing test files go in when we ask for test ideas.
The poster
The other half reads what Claude sent back:
def post(result_file, save):
data = json.loads(read(result_file))["structured_output"]
if "suggestions" in data:
for s in data["suggestions"]:
print(f"ADD TEST {s['scenario']} [{s['fixture']}]")
print(f"suggested {len(data['suggestions'])} test(s)")
return
found = data["findings"]
new = [f for f in found if f["status"] == "new"]
for f in new:
where = f"{f['file']}:{f['line']}"
print(f"COMMENT {f['severity']:<6} {where} {f['id']}")
for f in found:
if f["status"] == "unaddressed":
print(f"STILL OPEN {f['id']} (no new comment)")
print(f"posted {len(new)} comment(s)")
if save:
pathlib.Path("prior_findings.json").write_text(
json.dumps(found, indent=1))
It opens the structured result. Test suggestions are printed one per line. For a review, each new finding becomes a comment. Unaddressed ones are listed but not posted again. Then the findings are saved, so the next push can bring them back in. In a real runner, keep prior_findings.json as a CI artifact or cache between pushes.
Three runs, one pull request
The project's demo.py runs these steps locally with stand_in_claude.py in place of claude -p. The stand-in checks the real code with simple rules and answers in the CLI's JSON shape, so no API key is needed; every reply is a test model reply. With a real key, the workflow calls Claude.
$ python demo.py review --commit 1 --save
COMMENT high api/orders.py:12 shipped-cancel
COMMENT low api/orders.py:12 id-below-one
posted 2 comment(s)
$ python demo.py review
COMMENT low api/orders.py:13 id-below-one
COMMENT medium api/orders.py:23 float-cents
posted 2 comment(s)
$ python demo.py review --prior prior_findings.json
COMMENT medium api/orders.py:23 float-cents
STILL OPEN id-below-one (no new comment)
posted 1 comment(s)
- Push one: two comments, both new.
--savewrites them toprior_findings.json. - Push two, nothing in context: the shipped order is fixed, so that comment is gone. But
id-below-oneis posted again, a duplicate. - Push two with prior findings:
id-below-oneis marked still open with no new comment, the fixed one stays quiet, andfloat-centsis the only comment.
Existing tests: stop suggesting what you have
Ask for test ideas and Claude will happily suggest scenarios you already cover. The test file already has two:
from orders import cancel_order
def test_cancel_unknown_order_is_error(orders):
assert cancel_order(9999)["error"] == "order not found"
def test_cancel_shipped_order_is_rejected(orders):
assert cancel_order(1042)["error"] == "already shipped"
Without the test file in context, then with it:
$ python demo.py tests
ADD TEST cancel an unknown order [orders]
ADD TEST cancel a shipped order [orders]
ADD TEST cancel a packing order [orders]
ADD TEST cancel an id below one [orders]
ADD TEST cancel the same order twice [orders]
suggested 5 test(s)
$ python demo.py tests --tests api/orders_test.py
ADD TEST cancel a packing order [orders]
ADD TEST cancel an id below one [orders]
ADD TEST cancel the same order twice [orders]
suggested 3 test(s)
Five suggestions without, two of them already in the file. Three with, and every one is missing from the suite. Show it the tests you have, and it skips what they cover.
Test standards in CLAUDE.md
The third piece is the project CLAUDE.md, which Claude Code reads on its own, in CI too:
## Testing standards
- Use pytest. Every test takes the `orders` fixture from api/conftest.py.
- Write one test per behavior. Name it test_<action>_<case>.
- A valuable test covers a branch, an edge case or a failure path.
- Skip tests that only restate constants or data.
## Review criteria
- Report bugs and security issues. Skip minor style.
- Report only issues in lines that changed in this pull request.
It names the fixture once, says what makes a test valuable, and says what to skip. The review criteria sit in the same file. That's why every suggestion above carries [orders]. Run the same request from a folder with no CLAUDE.md:
$ python demo.py tests --tests api/orders_test.py --no-claude-md
ADD TEST cancel a packing order [none]
ADD TEST cancel an id below one [none]
ADD TEST cancel the same order twice [none]
ADD TEST ORDERS has two entries [none]
suggested 4 test(s)
The fixture is gone, and a test that only restates data, "ORDERS has two entries", slips in.
Break it: leave one piece out
| Left out | What the runs show | Fix |
|---|---|---|
| Prior findings | id-below-one posted a second time (2 comments instead of 1) | Pass prior_findings.json into the prompt |
| Existing tests | 2 of the 5 suggestions repeat what the suite covers | Pass the test files in |
| Standards in CLAUDE.md | Fixture becomes [none]; a data-restating test appears (4 suggestions) | Keep the standards in the committed CLAUDE.md |
Each leak has one fix: put it in the context.
How this shows up in a question
The scenario: after each new commit, the same review comments appear again. Telling the reviewer to "be conservative" is a general rule that says nothing about what was already said. Keeping only the overlap of two runs throws away real findings. Fewer commits just hides the problem. The fix is to pass the previous findings in and ask for only new or still-unaddressed issues. General confidence rules don't fix repeats; context does.
Common mistakes
- Not saving the findings. If the job doesn't keep
prior_findings.jsonbetween pushes, every run is push one again. - Adding a "fixed" status and posting it. A fixed finding should vanish, not become another comment.
- Re-posting unaddressed findings. List them in the job log; the original comment is still on the pull request.
- Asking for test ideas without the test files. You'll get scenarios you already have.
- Writing standards into the CI prompt only. Put them in CLAUDE.md, where developers' local sessions get them too.
Quick recap
| Input | Where it comes from | What it stops |
|---|---|---|
| Prior findings | Saved by the last run, added to the prompt | Repeated comments |
| Existing tests | Test files added to the prompt | Suggestions you already cover |
| Test standards, review criteria | CLAUDE.md, loaded by Claude Code | Missing fixture, low-value tests, style nits |
The CI review project, with the stand-in and all six commands, is in the community, free to join.
Try it yourself
Fix id-below-one in api/orders.py by adding if order_id <= 0: to cancel_order and returning a validation error (the stand-in looks for that exact <= 0 check), then run python demo.py review --prior prior_findings.json again. Before you run it, predict how many comments are posted and whether a STILL OPEN line remains.
Related course on Udemy
Claude Certified Architect - Foundations (CCAR-F) Exam Prep
Agentic loops, tools, MCP, Claude Code, prompts, structured output and context.View on Udemy ↗: Claude Certified Architect - Foundations (CCAR-F) Exam Prep (paid course, opens in a new tab)Related posts
CLAUDE.md, settings.json and Plugins: Which Claude Code File Advises, Which Enforces, Which Packages
Three needs in one repo: a test command, a rule that Claude must never read .env, and a shared deploy skill. See which file each belongs in, how the settings layers merge, and what a plugin manifest carries.
Authoring a Claude Skill: SKILL.md, Frontmatter, Progressive Disclosure and the Description That Triggers It
Pack a support team's ticket-triage routine into one skill folder, then watch three requests load one, two or all three levels: the catalog, the SKILL.md body, and a script whose code never enters the context.
One Change, Four Environments: Where a Claude Config Edit Lands in Dev, Staging, Prod and CI
Change one line in a repo and ask where it lands. A small resolver for bookshop-bot shows that a new model id in settings.json reaches only CI, a prompt bump reaches dev and CI, and a prod block edit reaches only prod.
Claude in the SDLC: Prompts in Git, a Change Gate by Path, a Claude Review That Advises and a Person Who Merges
Follow one prompt edit from a branch to a merge: version prompts and the model pin like code, keep the API key in GitHub Secrets, gate changes by path, let Claude review the diff, and leave the merge to a person.
