What Data Does the Codex Plugin Collect? A Complete Technical Breakdown

The Codex plugin collects a complete snapshot of your repository context—including Git status, staged and unstaged diffs, untracked files, and branch metadata—and packages it into a structured JSON payload for LLM analysis.

The openai/codex-plugin-cc repository implements a Git-aware code review system that automatically inspects your local repository to provide context for AI-powered reviews. When you request a review, the plugin gathers precisely what data the Codex plugin collects from your working directory to build a comprehensive evidence package for the language model.

Repository Data Collection Process

The data gathering is orchestrated by the collectReviewContext function in plugins/codex/scripts/lib/git.mjs. This function executes a multi-stage inspection process to capture the repository state.

Detecting Repository State

First, the plugin identifies the repository boundaries and current position. The getRepoRoot and getCurrentBranch functions determine the absolute repository path and active Git branch【/plugins/codex/scripts/lib/git.mjs#L89-L99】.

This establishes the cwd (current working directory) and branch name that anchor the review context.

Resolving Review Targets

The resolveReviewTarget function determines whether to review the working-tree changes or a specific branch diff【/plugins/codex/scripts/lib/git.mjs#L34-L90】. It supports multiple review modes:

  • Working-tree review: Examines staged, unstaged, and untracked files
  • Branch diff review: Compares the current branch against a base reference

Measuring Diff Size for Input Optimization

Before packaging data, the plugin measures the total diff size to decide between full content inclusion or lightweight summarization【/plugins/codex/scripts/lib/git.mjs#L30-L38】. This size-gating logic prevents sending payloads that exceed LLM context windows.

The measurement tracks fileCount and diffBytes to determine whether to use "inline-diff" mode (full diffs included) or "self-collect" mode (summary only with instructions for the LLM to request specific files).

What Data Is Included in the Review Payload

The collectReviewContext function assembles a JSON object containing specific metadata fields and a Markdown-formatted content block【/plugins/codex/scripts/lib/git.mjs#L92-L100】.

Core Metadata Fields

The payload includes these top-level properties:

  • cwd and repoRoot: The absolute path to the repository root
  • branch: Name of the current Git branch
  • target: The resolved review target containing mode, label, and baseRef (for branch comparisons)
  • fileCount: Total number of changed files detected
  • diffBytes: Total byte size of all diffs (used for size gating decisions)
  • inputMode: Either "inline-diff" or "self-collect" depending on size limits
  • collectionGuidance: Instructions for the LLM (e.g., "Use the repository context below as primary evidence.")
  • summary: Human-readable description (e.g., "Reviewing 3 staged, 1 unstaged, and 2 untracked file(s).")【/plugins/codex/scripts/lib/git.mjs#L54-L57】

Content Block Structure

The content field contains a Markdown-formatted block with:

  1. Git Status: Output of git status --short showing file categorization
  2. Staged Diff: Full git diff --cached output for staged changes
  3. Unstaged Diff: Full git diff output for unstaged changes
  4. Untracked Files: Either literal file contents (for small text files) or placeholder notes for binary files, directories, large files, or broken symlinks【/plugins/codex/scripts/lib/git.mjs#L31-L43】【/plugins/codex/scripts/lib/git.mjs#L96-L108】

Branch-Based Review Data

When reviewing a branch diff rather than working-tree changes, the payload additionally includes:

  • Commit log: History of commits in the branch range
  • Diff statistics: Summary statistics about the changes
  • Branch diff: Either the full diff content or a list of changed files when the diff exceeds size limits【/plugins/codex/scripts/lib/git.mjs#L69-L86】

Code Example: Accessing Collected Data

You can inspect exactly what data the Codex plugin collects by calling the collection functions directly:

// Example: obtaining the review context inside a Codex plugin
import { resolveReviewTarget } from "./scripts/lib/git.mjs";
import { collectReviewContext } from "./scripts/lib/git.mjs";

async function getReviewPayload(cwd) {
  // Determine what the user wants to review (auto-detect)
  const target = resolveReviewTarget(cwd, { scope: "auto" });

  // Gather the full repository context
  const context = collectReviewContext(cwd, target, {
    // optional limits – keep diffs small enough for the LLM
    maxInlineFiles: 3,
    maxInlineDiffBytes: 200 * 1024,
  });

  // The `context` object can now be sent to the LLM or used for debugging
  console.log("Collected", context.fileCount, "files, total diff size:", context.diffBytes);
  console.log("Input mode:", context.inputMode);
  console.log("Payload content:\n", context.content);
  return context;
}

This example demonstrates how to configure size limits (maxInlineFiles and maxInlineDiffBytes) to control when the plugin switches from full diff inclusion to summary mode.

Summary

  • The Codex plugin collects repository context exclusively from the local Git repository it runs inside, with no external telemetry or personal data gathering.
  • The collectReviewContext function in plugins/codex/scripts/lib/git.mjs assembles a JSON payload containing repository metadata, file counts, diff statistics, and Markdown-formatted Git output.
  • Size gating automatically switches between "inline-diff" mode (full content) and "self-collect" mode (summaries only) based on diffBytes and configured thresholds.
  • The payload includes Git status, staged diffs, unstaged diffs, and untracked file contents (or placeholders for binary/large files).
  • Branch-based reviews additionally include commit logs and diff statistics versus a base reference.

Frequently Asked Questions

Does the Codex plugin collect personal data?

No. According to the openai/codex-plugin-cc source code, the plugin only accesses the local Git repository where it is executed. It does not collect personal information, system telemetry, or data from outside the specified repository context.

How does the plugin handle large diffs?

The plugin implements size-gating logic that measures diffBytes before transmission. If the total diff size exceeds maxInlineDiffBytes (default 200KB) or the file count exceeds maxInlineFiles, it switches inputMode from "inline-diff" to "self-collect", sending only a summary with guidance for the LLM to request specific files on demand【/plugins/codex/scripts/lib/git.mjs#L30-L38】.

What Git commands does the plugin use to collect data?

The plugin executes specific Git commands to build the context: git status --short for file categorization, git diff --cached for staged changes, git diff for unstaged changes, git ls-files for untracked file detection, and git log with statistics for branch-based reviews【/plugins/codex/scripts/lib/git.mjs#L21-L25】【/plugins/codex/scripts/lib/git.mjs#L69-L86】.

Is the collected data sent to external servers?

The collected repository context is passed to the Codex LLM for analysis. The codex-companion.mjs script serves as the entry point that calls collectReviewContext and forwards the payload to the LLM API. The data is not used for telemetry or stored permanently; it is transmitted solely for the purpose of generating the requested code review.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →