Foredeck
DocsOpen ForedeckRequest access
  1. Foredeck
  2. Software factory guide
  3. AI code attribution

Guide · Published November 20, 2026

AI code attribution: measuring AI-written code in production

AI code attribution means recording, for every change you ship, the agent run that made it: which agent, which model, which prompt and instruction files, and what the run cost. On its own that's bookkeeping. Joined to deploys and to what each change did in production, it tells you which of your agent setups produce changes that last, and which ones produce rework.

On this page

  1. Definition
  2. What to record
  3. How to capture it
  4. Why % of code misleads
  5. Join it to outcomes
  6. Compare fairly
  7. Agents, not people
  8. Where Foredeck fits
  9. FAQ

What attribution should record

The unit is the change, usually one pull request, not the line and not the developer. For each change you want enough to answer “what made this, and under what conditions?” later, when you're looking at an incident or a quarter's numbers:

  • Author kind. Human, agent or mixed. Mixed is common and worth keeping separate: a person who rewrote half an agent's pull request produced something different from either.
  • The agent. The tool or harness that ran, and its version.
  • The model. Model names change every few months, and the same agent on a different model is a different worker.
  • The prompt and instructions. The task prompt, and the files that steer every run: CLAUDE.md, AGENTS.md, skills, hooks and permissions. Teams edit these weekly. If you don't version them, you can't tell whether last week's edit helped.
  • The run. An ID that ties the change to the session that produced it, with tokens, cost and duration.

Together, the agent, model and instructions are a setup. A setup is what you can change, so it's what you compare.

How to capture it

There are four common sources. They differ in how much setup they need and how much they tell you. Most teams end up using more than one, with the richer source winning when both are present.

Commit trailers

Many agents already sign their commits. Git trailers are Key: value lines at the end of a commit message (git interpret-trailers), and Co-authored-by is the one GitHub uses to credit more than one author on a commit (GitHub Docs). Claude Code adds attribution to commits and pull requests by default, and its attribution setting changes or hides it (Claude Code settings). A commit from it looks like this:

Add retry to the checkout webhook

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

The Linux kernel asks for a more structured tag on AI-assisted patches, naming the agent and the model version (kernel docs, AI Coding Assistants):

Assisted-by: Claude:claude-3-opus coccinelle sparse

Trailers cost nothing and survive in git history forever. Their limits: they only say an agent was involved, often not which model, never what the run cost, and anyone can delete or forget them. Treat them as evidence, not as a ledger.

Commit authors and pull request metadata

Hosted agents usually commit as their own bot account or a fixed email address, and many open pull requests from a branch with a known prefix, like claude/. Both are cheap signals. The branch is the weakest of all, since people rename branches and reuse prefixes, so use it only when no commit carries better evidence, and never let it turn a person's commit into an agent's. The pull request is also where a team can state things directly: the pipeline, the task it came from, a prompt version.

OpenTelemetry GenAI spans

The richest source is the run itself. OpenTelemetry's semantic conventions for generative AI define gen_ai.* attributes for model calls and agent operations: an invoke_agent span with gen_ai.agent.name, gen_ai.request.model and token counts in gen_ai.usage.input_tokens and gen_ai.usage.output_tokens. The conventions are still marked Development, and they have since moved to their own repository (agent spans spec), so expect names to shift and read both old and new ones. A run that exports spans can carry its own attribution:

span  invoke_agent my-agent
  gen_ai.operation.name       invoke_agent
  gen_ai.agent.name           my-agent
  gen_ai.request.model        my-model
  gen_ai.usage.input_tokens   182040
  gen_ai.usage.output_tokens  9311
  foredeck.change.external_id run-7f3a

Spans give you cost and the exact model, which trailers can't. What they lack is the link to the change: a trace knows the run, not the pull request it ended up in.

Agent-run IDs

That link is the run ID. Stamp an ID on the run before it starts, carry it into the pull request or the spans, and you can join the two later. If the run starts before the pull request exists, use an ID you control, such as the task key or a generated run ID, and resolve it to the change when the pull request opens. One change can have several runs (an author, a reviewer, a fixer), so the join is many to one.

Why “% of code written by AI” misleads

The number that shows up in board decks is a share of lines. Google said in October 2024 that “more than a quarter of all new code at Google is generated by AI, then reviewed and accepted by engineers” (Alphabet Q3 2024 remarks). It's a fine adoption number. As a measure of what agents do for you, it has problems:

  • It counts volume, not value. Lines are easy to produce. GitClear's analysis of 211 million changed lines found duplicated blocks rising and, in 2024, copy/pasted lines exceeding moved lines for the first time (GitClear). A metric that rises with duplication rewards it.
  • It can't see what happened next. A change that was reverted the next day still counts. So do lines a person later rewrote.
  • Its boundary is fuzzy. Is an accepted autocomplete AI-written? A line a person edited after the agent wrote it? Every tool draws the line differently, so two teams' percentages rarely measure the same thing.
  • It points at people. A per-team or per-person share turns into a target, and then into a reason to label work one way or the other.

Count changes instead, and ask what happened to them.

Joining attribution to deploys and outcomes

Attribution becomes useful at the point most tools stop: the merge. To follow a change into production you need three more joins.

  1. Change to commits. Record the commit SHAs that make up each change, the final ones after squash or rebase.
  2. Commits to deploys. Every production deploy reports the SHAs it shipped, everything since the previous deploy. Now each change has a time it reached users.
  3. Deploys to outcomes. Reverts, rollbacks, alerts and incidents get tied back to the changes they touched. A revert names the commits it undoes. A rollback removes every change shipped since the version it returns to.

Then pick a survival window, a week say, and give each change an outcome when it closes: it survived, or it regressed, was reverted, rolled back or turned off behind its feature flag. When a rollback removes several changes at once, don't guess which one caused it. Mark it unassigned until a person says, or you'll blame the wrong setup. And a change behind a flag that only your own team sees hasn't been tested by users yet, so start its window when the flag reaches its target rollout, not at the deploy.

With outcomes in hand, the measures that matter for a software factory fall out of the data: change survival rate, cost per surviving change, and rework, the cost of later changes that touched the same files inside the window. The software factory guide covers those measures in more depth.

Comparing agents and models fairly

Once every change has a setup and an outcome, the tempting move is a leaderboard. A raw one will mislead you. These rules keep the comparison honest.

  • Credit one setup per change. When several runs touched a pull request, give the change to the setup with the largest authoring spend, and list the others as contributors. Runs that only reviewed shouldn't take credit. Count the cost once.
  • Hide small groups. A survival rate over four changes is mostly luck. Show the counts and hold back rates until a group has enough changes.
  • Show the risk mix. The setup you trust with migrations will look worse than the one doing copy fixes. Show each setup's share of high-risk work beside its numbers, or filter to one tier.
  • Compare in the same window. Use changes that reached an outcome in the same period, so a quiet month for one setup isn't set against a busy one for another.
  • Version the harness. Hash the instruction files at the commit the run started from. When the hash changes, you get a before and an after instead of one blended number.
  • Don't call it significant. Factory samples are small. Report the sample size and the uncertainty, and treat a difference as a reason to run a controlled comparison, not as a verdict.

Here is what a fair comparison of two setups over 30 days might look like:

SetupResolvedSurvivedCost per surviving changeHigh-risk share
Agent A, model X6491%$4.108%
Agent B, model Y4183%$6.7029%

Illustrative numbers, not customer data. Agent B looks worse on both measures, but it was given more than three times the share of high-risk work. Filter both to the same risk tier before drawing a conclusion.

Privacy: compare agents, never people

Attribution data sits close to people. Every agent run was started by someone, and every pull request has a human reviewer. It's easy to slide from “which model survives better” to “whose agent work survives better”. Don't.

  • Group by setup, not by person. Agent, model, prompt and harness version are the dimensions. A person isn't one of them, and survival is never a target or quota for anyone.
  • Keep honest labeling cheap. If marking work as agent-written can hurt someone, people stop marking it, and your data quietly breaks.
  • Send hashes and IDs, not content. Attribution can be computed where the code lives, in CI, and leave without commit messages, emails, file paths or diffs. A hash of the instruction files is enough to tell two versions apart.

Where Foredeck fits

Foredeck is the stats and control plane for your software factory. Each pull request becomes a Change, attributed as human, agent or mixed, with its agent, model and prompt version. Its attribution rules read commit trailers first, then known agent authors, then branch prefixes as a fallback, and Foredeck's GitHub Action, not yet published, works them out on the runner without sending commit messages, emails, file paths or diffs. Agent runs arrive as OpenTelemetry spans with gen_ai.* attributes and a Change ID or your own run ID, so each Change carries its runs, tokens and cost.

Deploy markers start each Change's survival window, and it ends with an outcome: survived, regressed, reverted, rolled back or turned off. The factory scorecard compares setups on survival and cost per surviving change, with one credited setup per Change, small groups hidden and harness versions from a prompt fingerprint that sends only hashes. It groups by agent, model and harness, never by person. You stay at the helm of a light factory, deciding the next step from what the last Change did.

Request accessRead the software factory guide →

AI code attribution FAQ

What is AI code attribution?

Recording, for each change that ships, which agent run made it: the agent, the model, the prompt and instruction files it worked from, and what the run cost. The point is to join that record to what the change did in production, so you can tell which setups produce changes that last.

What is the difference between AI code attribution and AI code provenance?

The terms overlap. Provenance usually means the origin of a piece of code: was it generated, by what tool, from what source. Attribution, as used here, is narrower and more practical: tying each shipped change to the run that made it, so outcomes can be compared by agent, model and prompt.

Is a Co-Authored-By trailer enough to measure AI-written code?

It tells you an agent was involved, and sometimes which model. It doesn't tell you what the run cost, which instructions it had, or how much of the change the agent wrote. Use trailers as a zero-setup baseline and add run telemetry, such as OpenTelemetry gen_ai spans, where you can.

Should AI code attribution be used to evaluate engineers?

No. Attribution exists to compare setups: agents, models, prompts and harness versions. Ranking people by how much AI-written code they merge rewards volume, punishes careful work and makes people stop labeling agent work honestly, which breaks the data you were collecting.

© 2026 ForedeckBuilt for light factories, with people at the helm.HomeDocsinfo@foredeck.ai