CertSafari
    Anthropic Claude Certified Architect – Professional (CCAR-P) - December 7 onwards· Lessons

    Domain 7 · Lesson 39/39

    Human ownership of AI-generated code: review gates, CI agents and secrets

    Accountability for AI-Generated Code

    17 min read
    2.67% of exam
    12 sources
    Published 18 Nov 2026
    Docs as of 18 Nov 2026

    What you will be able to do

    • Explain why an engineer stays accountable for code an agent wrote, and why 'Claude already checked it' does not move that accountability
    • Spot when an AI review is being treated as a sign-off, and name the control that keeps a human approving every change to main
    • Limit a CI agent's permissions so that it can propose changes but a person still owns the merge
    • Pick controls that keep credentials out of agent-generated code, and explain why rules that rely on a prompt or a reviewer's memory are weaker

    Key concept

    Outcome ownership — The person who merges or ships a change is responsible for what it does, whether a human or an agent wrote it. Review, tests and gates exist so that this person can carry that responsibility. None of them takes it over.

    1.Who owns code an agent wrote

    The engineer who ships a change owns it, no matter who typed it. Claude Code can write a feature, its tests and its pull request description in one session. When that code breaks in production, the agent cannot answer for it. The engineer who merged it does. The AI Fluency framework calls this competency Diligence: owning the final result fully, regardless of AI's role. One sentence sums it up: you own the outcome, not the output. "AI wrote it" explains nothing and excuses nothing.

    Ownership is a practical test, not only a principle. Before shipping, the owner should be able to explain what the code actually does, not just what it should do. They should know whether the acceptance tests and edge cases still pass, and how they will find out whether it works after launch. This matters more for AI-generated code because it fails in predictable places. AI output is often technically complete but misses the point. It also has known blind spots in concurrency, security, and anything that only breaks at scale. A reviewer who skims a diff that compiles is checking exactly what the agent is already good at.

    Being open about AI's role is part of ownership. Asking 'have you been transparent about AI's role?' is one of the responsibility checks before shipping. Teams that build on agents keep a record they can audit. One medical-coding startup has auditors review both the agent's output and its reasoning, and says that 'everything is versioned and auditable.' That record does not replace a named human owner. It lets that owner, and anyone auditing them later, see what the agent did.

    Checkpoint 1 of 8· Check yourself

    Claude Code wrote a feature, its tests and the PR description in one session. The PR description says Claude generated the change. A reviewer saw that the diff compiled and the tests passed, then merged it. A week later it fails in production because of a concurrency bug. Which statement matches how ownership works here?

    Sources123

    2.Why an AI review is not the accountable approval

    AI review finds problems. It does not approve anything. Managed Code Review sends several agents over the diff and the surrounding code, filters out false positives, ranks the findings by severity, and posts them as inline comments plus a check run named Claude Code Review. That check run never concludes as a failure. A review only reads the diff and the surrounding code. It does not build or run anything, and inside a review its repository access is read-only. It is designed to inform a human decision, not to make one.

    The same applies to the other ways Claude can review code. /code-review checks your branch in a fresh subagent that never saw your conversation, so the reasoning that produced the code does not sway it. A custom reviewer subagent with only Read, Grep, Glob cannot edit anything. Both make good second readers. Anthropic's guidance on automated security reviews states the limit plainly: they should complement, not replace, your existing security practices and manual code reviews.

    The failure to watch for is quiet. Engineers start merging agent-authored pull requests after a skim, because a Claude review already ran. Each merge then has nobody actually responsible for it. The author handed responsibility to the agent, and the agent never had any. Making that Claude review a required status check does not fix this. It just turns 'Claude approved it' into an official rule.

    Ways Claude can review code. All of them inform a human approval; none replaces it
    OptionWhat starts itWhere it runs
    Code ReviewPull request activity, or an @claude review commentAnthropic infrastructure
    /code-reviewYou run the command on your branchYour Claude Code session
    Claude in your own CIPipeline events, such as every pull requestYour own CI runners
    Your own reviewer subagent or skillYou or Claude invoke it during a sessionWherever you run Claude Code

    Checkpoint 2 of 8· Check yourself

    A platform lead suggests making the Claude Code Review check run a required status check. Engineers could then merge agent-authored pull requests after a quick skim. What does this change about accountability for those merges?

    Sources456

    3.The control that keeps a human on every merge

    Human ownership survives only if the merge cannot happen without a person approving it. Claude Code's best-practices guide asks the same closing question of every agent workflow: where does the result go, and who signs off? Its answer is a PR, a comment or a summary, and then a person approving the merge, the deploy, or anything else you can't take back. The teams quoted in Anthropic's startup guide are not having agents merge to main and hoping for the best.

    The control that achieves this is enforced on the protected branch. For example, branch protection on main can require an approving review from a code owner who did not write the change. Two details make it work. Enforcement means the platform blocks the merge, so nobody has to remember the rule. Independence means the approver is someone other than the author, the same reason /code-review uses a reviewer that never saw the conversation.

    Other controls look similar but fail one of those two tests. A pull request template with a 'I read every line' checkbox is a request, and the reader who skims the code will skim the checkbox too. The reviewer subagent example in the best-practices guide shows the difference: its read-only limit is enforced by Claude Code rather than requested in a prompt. A required status check that runs another Claude session is enforced, but no human approves anything. Setting the agent's permission mode to plan changes how the code gets written, not who signs off on the merge.

    Testing candidate controls against enforcement and human independence
    ControlEnforced by the platform?Independent human approves?
    Required approval from a non-author code owner on mainYesYes
    Required status check running a separate Claude reviewYesNo
    PR template checklist confirming every line was readNoSelf-attested by the author
    Default permission mode set to planShapes authoring onlyNo

    Checkpoint 3 of 8· Match them up

    A team is weighing four controls for agent-authored changes that reach main. Match each control to how it fares on the two tests of enforcement at the merge and an independent human approver.

    Tap a term, then the definition that fits it.

    Checkpoint 4 of 8· Exam question

    A 40-engineer company has adopted Claude Code CLI. Metrics show engineers merging agent-authored pull requests after a quick skim because "Claude already checked it." Leadership wants the control that keeps a human accountable for every change reaching main. Which control should the platform team put in place?

    Sources53

    4.Agents in CI: let them propose, never let them merge

    An agent running in CI should be able to open pull requests and nothing more powerful. When Claude Code runs in GitHub Actions from issue comments, a workflow is writing code with nobody watching the session. Its permissions decide whether human review is something the platform enforces or something everyone just hopes happens. The best-practices checklist asks what the agent is allowed to touch: permission rules, dontAsk, the sandbox, a worktree, the one branch it may push to.

    The Claude Code GitHub Action has checks on who can start a run. On issue and pull request events, the user who triggers it must have write access to the repository. It also rejects a bot actor unless you list it in allowed_bots, which keeps bots from triggering Claude in a loop. Those checks control who can start a run. They do not control what the run can merge. That limit comes from how you scope the workflow token. Give it branch-write and pull-request scopes, no merge rights, and no ability to bypass branch protection. The pull requests it opens then go through the same required code-owner approval as everyone else's. The workflow files themselves are sensitive: Anthropic's security-guidance plugin flags edits under .github/workflows/ because they can grant repository-level permissions.

    Two shortcuts quietly remove the human. Auto-merge that triggers on green checks plus a Claude approval comment means no person ever approves the change. Running the workflow under a repository admin's personal access token means the merge carries a person's name although that person never reviewed it, and admin rights can usually bypass protections. Signed commits from the agent's bot identity show which identity pushed a commit. They do not show that anyone reviewed it.

    Anthropic's own incident-response agent shows the model working under pressure. On its own, it asked a code-writing Claude instance over Slack to fix a problem. The fix went to a pull request that a human reviewed before it was pushed to production. The agent behaved in a way nobody had planned, and the control still held, because the only write-like action still required a human review.

    Checkpoint 5 of 8· Check yourself

    Your team runs the Claude Code GitHub Action from issue comments, so it writes code without anyone watching the session. Which workflow setup keeps a person accountable for each change the agent makes that reaches main?

    Checkpoint 6 of 8· Exam question

    A team runs Claude Code in a GitHub Actions workflow that opens pull requests from issue comments. Security wants human ownership of everything merged. Which TWO measures achieve this? Choose two.(Select 2)

    0 of 2 selected

    Sources5789

    5.Keeping credentials out of agent-generated code

    Secrets need controls that work even when a reviewer misses something. In a large AI-generated diff, a hard-coded key is one line among hundreds. The reliable controls work in two places: before the agent sees a secret, and at the moment code tries to enter the repository.

    On the input side, a Claude Code permission deny rule stops the agent from reading local secret files at all. A key the agent never read cannot end up pasted into a file or a log. Deny rules hold firm: --allowedTools adds allow rules for one session, but a deny rule from any settings file still blocks the tool it names. Set the rule in project or managed settings so that it applies to everyone on the team.

    A permissions block whose deny rule stops Claude from reading .envjson
    {
      "permissions": {
        "allow": ["Bash(npm run *)"],
        "ask": ["Bash(git push *)"],
        "deny": ["Read(./.env)"],
        "defaultMode": "acceptEdits"
      }
    }

    On the output side, the strongest check is deterministic and runs at the gate. A repository-side scanner that rejects any push containing a recognised credential pattern stops the key before it lands in history. Anthropic's advice on verification loops follows the same principle: a deterministic, project-specific rule catches what a generic linter or a person will miss, and anything you keep enforcing by hand belongs in an automated check. Compare the weaker options. A CLAUDE.md rule saying 'read keys from environment variables' is guidance the agent usually follows, not a block. Asking reviewers to search diffs for 'password' still depends on a busy person remembering. A nightly scan of the default branch finds the key only after it has been committed, when the only remaining fix is rotating it.

    Pattern warnings inside the session help, but they are not a gate. The security-guidance plugin lets a repository define rules such as substrings sk_live_ and AKIA, and attach a reminder like 'Hardcoded API key prefix. Load credentials from the secret manager.' The reminder is warning text added to Claude's context. It nudges the author. The push-time rejection is what stops the key.

    Checkpoint 7 of 8· Match them up

    An agent-generated diff of several hundred lines contains one hard-coded API key. Match each control to how it handles that key.

    Tap a term, then the definition that fits it.

    Checkpoint 8 of 8· Exam question

    A platform team wants to prevent credentials from reaching the repository through agent-generated code. Reviewers sometimes miss hard-coded keys in large diffs. Which TWO controls are the most reliable? Choose two.(Select 2)

    0 of 2 selected

    Sources10118

    Sources

    (12)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “You own the outcome, not the output.”
      ↩︎ Who owns code an agent wrote
      “Have you been transparent about AI’s role?”
      ↩︎ Who owns code an agent wrote
      “You own the outcome, not the output. “AI wrote it” explains nothing and excuses nothing.”
      ↩︎ Checkpoint
    2. 2.
      “AI has predictable blind spots in concurrency, security, and anything that only breaks at scale.”
      ↩︎ Who owns code an agent wrote
    3. 3.
      “Everything is versioned and auditable”
      ↩︎ Who owns code an agent wrote
      “none of these startups are having agents merge to main and hoping for the best.”
      ↩︎ The control that keeps a human on every merge
    4. 4.
      “a review works from reading the diff and the surrounding code, without building or running your code.”
      ↩︎ Why an AI review is not the accountable approval
      “The check run doesn’t conclude as a failure.”
      ↩︎ Prediction
    5. 5.
      “/code-review reviews the diff in a fresh subagent that never saw your conversation. It isn’t swayed by the reasoning that produced the code.”
      ↩︎ Why an AI review is not the accountable approval
      “and then a person approving the merge, the deploy, or anything else you can’t take back.”
      ↩︎ The control that keeps a human on every merge
      “Now it’s a reviewer that can’t edit anything, and that limit is enforced by Claude Code rather than requested in a prompt.”
      ↩︎ The control that keeps a human on every merge
      “What’s it allowed to touch? Permission rules, dontAsk, the sandbox, a worktree, the one branch it may push to.”
      ↩︎ Agents in CI: let them propose, never let them merge
      “that limit is enforced by Claude Code rather than requested in a prompt.”
      ↩︎ Exam trap 2
      “Where does the result go, and who signs off? A PR, a comment, or a summary, and then a person approving the merge”
      ↩︎ Checkpoint
      “Where does the result go, and who signs off? A PR, a comment, or a summary, and then a person approving the merge”
      ↩︎ Checkpoint
    6. 6.
      “they should complement, not replace, your existing security practices and manual code reviews.”
      ↩︎ Why an AI review is not the accountable approval
      “they should complement, not replace, your existing security practices and manual code reviews.”
      ↩︎ Exam trap 1
    7. 7.
      “on issue and pull request events, the triggering user must have write access to the repository.”
      ↩︎ Agents in CI: let them propose, never let them merge
      “the Claude Code GitHub Action rejects a bot actor unless you list it in allowed_bots, which keeps bots from triggering Claude in a loop.”
      ↩︎ Agents in CI: let them propose, never let them merge
    8. 8.
      “Workflow files: edits under .github/workflows/, which can grant repository-level permissions”
      ↩︎ Agents in CI: let them propose, never let them merge
      “Hardcoded API key prefix. Load credentials from the secret manager.”
      ↩︎ Keeping credentials out of agent-generated code
    9. 9.
      “The fix went to a pull request that a human reviewed before pushing it to production.”
      ↩︎ Agents in CI: let them propose, never let them merge
      “the only write-like action still required a human review.”
      ↩︎ Exam trap 3
      “the only write-like action still required a human review.”
      ↩︎ Checkpoint
    10. 10.
      “a deny rule from any settings file still blocks a tool it names”
      ↩︎ Keeping credentials out of agent-generated code
      “a deny rule from any settings file still blocks a tool it names”
      ↩︎ Exam trap 4
    11. 11.
      “Anything you keep having to enforce by hand as a manual check qualifies for capture as a loop.”
      ↩︎ Keeping credentials out of agent-generated code
      “so every session applies the same checks automatically instead of relying on a human to remember them”
      ↩︎ Checkpoint

    Also cited

    Ready to test yourself?

    Practise Anthropic Claude Certified Architect – Professional (CCAR-P) - December 7 onwards in quiz mode.

    Spotted a mistake, or was something unclear? Tell us.