> ## Documentation Index
> Fetch the complete documentation index at: https://docs.weaveos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PR lines of code

> Lines of code in merged PRs, split into human, AI, and codegen

## How it works

The **Lines of code** chart (grouped **by LOC type**) shows how many lines changed in merged pull requests, split into three buckets:

| LOC type | What it represents |
| - | - |
| **Human** | Lines a developer wrote by hand |
| **AI** | Lines written with AI coding assistants (Cursor, Copilot, Claude Code, etc.) |
| **Codegen** | Lines in files Weave filters out before attribution: generated code, lock files, docs and config files (such as `.md`, `.json`, and `.yaml`), and your custom ignore patterns |

This chart counts **raw line changes** in merged PRs. It is separate from [code output](/metrics/code-output), which measures the estimated effort of a change.

Codegen is tracked separately so large generated-file PRs (protobuf, GraphQL/SQLC codegen, lock files, etc.) do not inflate human or AI numbers.

## Calculation

For each merged PR, Weave counts lines added and deleted across all changed files.

### Step 1: Raw vs filtered LOC

* **Raw LOC** — total lines added and deleted in the PR
* **Filtered LOC** — lines in files Weave treats as meaningful source code

Files excluded from filtered LOC include generated outputs (for example `*.pb.go`, `*.sql.go`, `*.generated.ts`), lock files, minified assets, and paths under `vendor/`, `node_modules/`, `dist/`, and similar directories. Your organization can also configure custom ignore patterns.

**Formula:**

```
codegen LOC = raw LOC − filtered LOC
```

### Step 2: Split filtered LOC into human and AI

The remaining **filtered LOC** is split between human and AI using the same attribution strategies as [AI output attribution](/analysis/ai-output-attribution) — git notes, API telemetry, co-authorship metadata, or time-matched AI activity — but weighted by each commit's filtered line count instead of output estimates.

**Formulas:**

```
AI LOC     = filtered LOC × AI attribution share
human LOC  = filtered LOC × human attribution share
```

AI and human shares sum to 100% of filtered LOC. Codegen is excluded from this split.

### Example

A merged PR changes 10,000 lines total:

* 7,000 lines are in generated protobuf files → **codegen**
* 3,000 lines remain as filtered LOC
* Attribution finds 80% AI, 20% human on those 3,000 lines → **2,400 AI**, **600 human**

Total chart breakdown: 7,000 codegen + 2,400 AI + 600 human = 10,000 raw LOC.

## Where you'll see this

* **Overview** and **AI usage** dashboards — **Lines of code**, grouped **by LOC type**
* **PR LOC AI percentage** — `AI / (AI + human)`, excluding codegen

## Related metrics

* [AI lines of code](/metrics/ai-code-loc): lines from AI tool telemetry, git attribution notes, and AI co-authored commits, not this page's human, AI, and codegen split
* [AI output percentage](/metrics/ai-output-percentage): AI share of [code output](/metrics/code-output), not raw LOC
* [AI output attribution](/analysis/ai-output-attribution): how Weave decides which lines are AI vs human

## Technical details

<AccordionGroup>
  <Accordion icon="braces" title="What counts as codegen?">
    Codegen is any line change in a file Weave filters out before attribution. Common examples:

    * Protobuf and gRPC outputs (`*.pb.go`, `*_pb2.py`)
    * SQLC and GraphQL codegen (`*.sql.go`, `*.generated.ts`)
    * Lock files and dependency vendoring (`package-lock.json`, `go.sum`, `*.lock`, `vendor/`)
    * Minified files and image assets (`.min.js`, `.svg`)
    * Documentation and config files (`.md`, `.json`, `.yaml`)

    Files marked as generated in `.gitattributes` (via Linguist) and organization-specific ignore patterns are also excluded.
  </Accordion>

  <Accordion icon="circle-question" title="How is this different from AI lines of code?">
    **[AI lines of code](/metrics/ai-code-loc)** comes from connected AI tool telemetry (how much each assistant reports a developer used it day to day), plus git attribution notes and commits co-authored by AI tools. For each person, day, and tool, Weave keeps one source: git attribution first, then telemetry, then co-authored commits.

    **PR lines of code (by LOC type)** comes from git diffs in merged PRs. We attribute those diffs to human, AI, or codegen. The two metrics answer different questions and may not match exactly.
  </Accordion>

  <Accordion icon="chart-line" title="Why exclude codegen from AI percentage?">
    Codegen lines come from generated, dependency, documentation, and config files rather than source code you write. Excluding them from **PR LOC AI percentage** keeps the metric focused on how much of your *meaningful* code changes came from AI assistants.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.