Reviewing What the Agent Did

Use git diff to inspect agent changes, read the structured result JSON, run tests, and decide whether to accept, reject, or request a revision.

Reviewing What the Agent Did

What you'll learn

Build a reliable review workflow: git diff, reading structured results, running tests, and deciding whether to accept, reject, or request a revision.


The review mindset

Treat agent-authored code the same way you'd treat a pull request from a junior developer — read every changed line, check it matches the spec, and verify the tests actually cover the behaviour.

Your review checklist:
1. Does the diff match what the issue asked for?
2. Did the agent change anything outside the specified scope?
3. Do the tests run and pass?
4. Does the code follow existing patterns in the project?
5. Are there any obvious bugs, security issues, or missing error handling?


Reading the diff

cd ~/projects/my-api

# All changes since your last commit
git diff

# Only staged changes (after git add)
git diff --staged

# Summary — files changed and line counts
git diff --stat

# A specific file
git diff src/routes/health.ts

For larger changes, use your editor's diff view:

# VS Code
code --diff src/app.ts

# Or open the project and use the Source Control panel
code .

Reading the structured result

The result_structured JSONB field gives you a machine-readable summary:

curl -s $BASE/companies/$COMPANY_ID/issues/$ISSUE_ID \
  | python3 -c "import sys,json; r=json.load(sys.stdin); print(json.dumps(r['result_structured'], indent=2))"
{
  "summary": "Added health endpoint",
  "changedFiles": [
    { "path": "src/routes/health.ts", "action": "created",  "linesAdded": 12, "linesRemoved": 0 },
    { "path": "src/app.ts",           "action": "modified", "linesAdded": 2,  "linesRemoved": 0 }
  ],
  "commandsRun": ["npm test"],
  "testsRan": true,
  "testsPassed": true,
  "errors": []
}

If testsPassed is false or errors is non-empty — the agent tried but hit a problem. Read the result text field for the full explanation.


Three review outcomes

✅ Accept — commit the changes

cd ~/projects/my-api

# Review one more time
git diff --stat

# Stage all agent changes
git add -A

# Commit with a clear message referencing the issue
git commit -m "feat: add GET /health endpoint

Paperclip issue: pcl-issue-01929f3a
Agent: claude-code-agent"

# Optionally push to your branch
git push origin paperclip-agent

✏️ Revise — the change is close but needs adjustment

If the diff is mostly right but missing something (no test, wrong field name, etc.), you have two options:

Option A — Edit manually and commit:

# Fix the issue yourself
vim src/routes/health.ts
git add -A
git commit -m "feat: add /health endpoint (with manual fix for missing error handling)"

Option B — Create a follow-up issue for the agent:

curl -X POST $BASE/companies/$COMPANY_ID/issues \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Fix: /health endpoint missing error handling",
    "description": "The health endpoint in `src/routes/health.ts` was just added but is missing a try/catch. If `process.uptime()` throws for any reason the server will crash.\n\nAdd a try/catch and return `{ status: \"error\", message: err.message }` with a 500 status code.\n\n## Acceptance criteria\n- [ ] try/catch wraps the handler\n- [ ] npm test passes",
    "assigned_agent_id": "'$AGENT_ID'",
    "priority": "high"
  }'

❌ Reject — discard all agent changes

cd ~/projects/my-api

# Discard all uncommitted changes
git checkout -- .
git clean -fd          # remove untracked files

# Verify clean state
git status             # should say "nothing to commit"

Update the issue status so it's tracked:

curl -X PATCH $BASE/companies/$COMPANY_ID/issues/$ISSUE_ID \
  -H "Content-Type: application/json" \
  -d '{"status": "rejected", "rejection_note": "Wrong approach — used raw SQL instead of Drizzle ORM"}'

Common review red flags

What you see What to do
Agent modified a file outside the scope Discard or manually revert that file with git checkout -- path/to/file
Tests were added but don't actually test the new code Accept the feature, create a follow-up issue to improve tests
TypeScript errors (npx tsc --noEmit fails) Fix or create follow-up issue
Agent used a different library/pattern than the rest of the codebase Accept if functionally correct, create follow-up to refactor
npm test fails Always reject or fix before committing

Checkpoint ✓

Sign in for progress tracking & Q&A →