Skip to content

Deliver canonical AGENTS.md to Claude Code and Codex root instructions - #138

Merged
yourconscience merged 1 commit into
mainfrom
feat/root-instructions
Aug 21, 2026
Merged

Deliver canonical AGENTS.md to Claude Code and Codex root instructions#138
yourconscience merged 1 commit into
mainfrom
feat/root-instructions

Conversation

@yourconscience

@yourconscience yourconscience commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Extends RootInstructionsCapability (today Droid-only) to Claude Code and Codex:

  • ~/.claude/CLAUDE.md -> <config-root>/AGENTS.md
  • ~/.codex/AGENTS.md -> <config-root>/AGENTS.md

Sync/inspect/report/doctor paths are generic over the capability, so both harnesses inherit missing/drifted/conflict handling: missing links are created on sync, drifted links re-pointed, non-symlink files reported as conflicts and never touched without confirmation. One canonical AGENTS.md edit now reaches Claude Code, Codex, and Droid.

Tests: table-driven inspect coverage (missing/synced/conflict) for both harnesses, native-path assertions, sync-application test; one existing claude-code report test updated to pre-create the link, matching post-setup reality. README documents the surface.

Summary by Sourcery

Propagate canonical root instructions to Claude Code and Codex through their native instruction paths.

New Features:

  • Link the canonical ~/.agents/AGENTS.md root instructions into Claude Code and Codex native instruction paths alongside Droid.

Enhancements:

  • Extend root-instruction status and synchronization behavior across supported harnesses, including detection of missing, synchronized, drifted, and conflicting paths.
  • Document the shared root-instructions surface and native harness paths.

Documentation:

  • Document shared root instructions, synchronization behavior, and conflict handling in the README.

Tests:

  • Add coverage for Claude Code and Codex native paths, root-instruction inspection states, and synchronization of missing links.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@sourcery-ai

sourcery-ai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Reviewer's Guide

Extends the existing root instructions symlink capability to Claude Code and Codex so they both use a canonical AGENTS.md under the dotagents repo, and adds table-driven tests plus documentation to verify native paths, inspection states, and sync behavior across harnesses.

File-Level Changes

Change Details Files
Wire Claude Code and Codex harnesses into the shared RootInstructionsCapability so they each point their native root-instruction file at the canonical AGENTS.md.
  • Register RootInstructionsCapability for the Claude Code harness with Path resolving to ~/.claude/CLAUDE.md and Expected resolving to /AGENTS.md.
  • Register RootInstructionsCapability for the Codex harness with Path resolving to ~/.codex/AGENTS.md and Expected resolving to /AGENTS.md.
cmd/dotagents/harness.go
Add focused tests that validate native paths, inspect behavior (missing/synced/conflict), and sync application for Claude Code and Codex root instructions.
  • Introduce helpers to retrieve the RootInstructionsCapability for Claude Code and Codex and panic if misconfigured.
  • Add TestRootInstructionsNativePaths to assert the expected link and canonical AGENTS.md locations for both harnesses.
  • Add table-driven TestInspectClaudeAndCodexRootInstructions to cover missing, synced, and conflict states and ensure conflicts are recorded.
  • Add TestApplyAgentRootInstructionSyncClaudeAndCodex to verify that sync creates the appropriate symlink from each harness’s native path to the canonical AGENTS.md.
cmd/dotagents/root_instructions_test.go
Update sync tests to reflect the new canonical AGENTS.md setup for Claude Code.
  • Pre-create AGENTS.md under the repo root and a symlink at ~/.claude/CLAUDE.md pointing to it in TestInspectAgentAcceptsMatchingNativeCopyAndRejectsDifferentContent to match post-setup reality.
cmd/dotagents/sync_test.go
Document the canonical AGENTS.md root instruction file and how it is linked into each harness’s native memory path.
  • Add README section explaining ~/.agents/AGENTS.md as the single root instruction file and describing how dotagents sync links it into Claude Code, Codex, and Droid, including drift/conflict reporting behavior.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The helper functions claudeCodeRootInstructions and codexRootInstructions panic on configuration issues even when called from tests; consider returning *RootInstructionsCapability and using t.Fatalf in the tests instead so failures are scoped and reported via the testing framework.
  • In TestRootInstructionsNativePaths, the table-driven assertions run directly in the parent test; wrapping each case in t.Run(tc.agent, ...) would make failures easier to attribute and keep the pattern consistent with the other table-driven tests you added.
  • The agent/table definitions for Claude Code and Codex in TestInspectClaudeAndCodexRootInstructions and TestApplyAgentRootInstructionSyncClaudeAndCodex are very similar; consider extracting a shared table or small helper to reduce duplication and keep the mapping between agent, dir, and filename centralized.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The helper functions `claudeCodeRootInstructions` and `codexRootInstructions` panic on configuration issues even when called from tests; consider returning `*RootInstructionsCapability` and using `t.Fatalf` in the tests instead so failures are scoped and reported via the testing framework.
- In `TestRootInstructionsNativePaths`, the table-driven assertions run directly in the parent test; wrapping each case in `t.Run(tc.agent, ...)` would make failures easier to attribute and keep the pattern consistent with the other table-driven tests you added.
- The agent/table definitions for Claude Code and Codex in `TestInspectClaudeAndCodexRootInstructions` and `TestApplyAgentRootInstructionSyncClaudeAndCodex` are very similar; consider extracting a shared table or small helper to reduce duplication and keep the mapping between agent, dir, and filename centralized.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@yourconscience
yourconscience merged commit dd80e78 into main Aug 21, 2026
4 checks passed
@yourconscience
yourconscience deleted the feat/root-instructions branch August 21, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant