Skip to content

AGENTS.md support for Claude Code#459

Merged
bl-ue merged 2 commits intomainfrom
agents-md-support
Feb 3, 2026
Merged

AGENTS.md support for Claude Code#459
bl-ue merged 2 commits intomainfrom
agents-md-support

Conversation

@bl-ue
Copy link
Member

@bl-ue bl-ue commented Feb 3, 2026

This PR makes Claude Code automatically use AGENTS.md if CLAUDE.md doesn't exist. No hooks or prompts required. Just run npx tweakcc@latest --apply.

Closes #391
Closes anthropics/claude-code#6235

You can even add custom file names to be used when CLAUDE.md doesn't exist.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

Adds support for alternative CLAUDE.md filenames via a new settings field, UI for managing alt names, a patch implementation that injects fallback filename lookup into CLAUDE.md readers, and documentation describing patch creation and registration workflows.

Changes

Cohort / File(s) Summary
Documentation & Guides
\.claude/skills/patch-creation/SKILL.md, CHANGELOG.md, README.md
New SKILL.md documenting patch creation/registration and examples; changelog entry for AGENTS.md support; README additions describing alternate CLAUDE.md names and configuration/UI usage.
Configuration & Types
src/defaultSettings.ts, src/types.ts
Added claudeMdAltNames to DEFAULT_SETTINGS and Settings type; added CLAUDE_MD_ALT_NAMES to MainMenuItem enum.
Patch Implementation
src/patches/agentsMd.ts, src/patches/index.ts
New writeAgentsMd() function that injects fallback logic to search alternative filenames; registered new agents-md patch and wired it into patch implementations (conditional on non-empty alt names).
UI Components
src/ui/App.tsx, src/ui/components/ClaudeMdAltNamesView.tsx, src/ui/components/MainMenu.tsx
Added ClaudeMdAltNamesView React Ink component for listing/adding/editing/moving/removing alt names; integrated view into App navigation and MainMenu.

Sequence Diagram

sequenceDiagram
    actor User
    participant App as App.tsx
    participant Menu as MainMenu
    participant View as ClaudeMdAltNamesView
    participant Context as SettingsContext
    participant Patcher as PatchSystem
    participant Writer as writeAgentsMd()

    User->>App: open app
    App->>Menu: render menu
    User->>Menu: select CLAUDE_MD_ALT_NAMES
    Menu->>App: navigate to view
    App->>View: render ClaudeMdAltNamesView
    User->>View: add/edit/delete alt name
    View->>Context: update claudeMdAltNames
    Context->>Patcher: settings changed (claudeMdAltNames)
    Patcher->>Writer: apply agents-md patch with altNames
    Writer->>Writer: locate CLAUDE.md reader pattern
    Writer->>Writer: inject alt-name lookup logic
    Writer->>Patcher: return patched file
    Patcher->>Patcher: persist patched file
    Patcher->>View: changes persisted
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hopped through code and found a trail,

AGENTS.md now joins the tale.
Alternate names bloom in rows so neat,
Patches applied — a carrot treat! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding AGENTS.md support to Claude Code. It is specific, concise, and directly reflects the primary objective.
Linked Issues check ✅ Passed The PR successfully implements AGENTS.md support with alternative filename handling [#391, #6235]. New patch applies fallback logic to check alternative names when CLAUDE.md is absent, configuration UI added, and system prompt references maintained.
Out of Scope Changes check ✅ Passed All changes directly support AGENTS.md functionality: new patch logic, alternative names configuration, UI for management, type definitions, default settings, and documentation. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch agents-md-support

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@bl-ue bl-ue changed the title AGENTS.md support for CC AGENTS.md support for Claude Code Feb 3, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @.claude/skills/patch-creation/SKILL.md:
- Around line 188-191: The example regex is too permissive—update the pattern
variable (currently defined as /(\someConfig\s*=\s*)\d+/) to a whitespace-free,
minified-friendly form (e.g., match "someConfig=" directly) so the replacement
only targets minified code; adjust the pattern symbol name `pattern` and ensure
the `file.match(pattern)` usage still captures the same group for replacement.

In `@README.md`:
- Around line 422-429: The example JSON for settings.claudeMdAltNames includes
an invalid empty string filename; update the example list used in the README
(the JSON block showing "settings": { "claudeMdAltNames": [...] }) to remove the
empty string so only valid filenames remain (e.g., ["AGENTS.md", "context.md"]).
🧹 Nitpick comments (2)
src/patches/agentsMd.ts (1)

159-177: Consider making the fallback pattern more specific.

The fallback pattern /(\})(}catch)/ is quite generic and could potentially match unintended locations within the function body if there are nested structures with }}catch. While limiting the search to file.slice(funcStart) helps, a more specific pattern could improve robustness.

That said, given the documented examples and that this is a fallback for older CC versions, this may be acceptable as-is if it works reliably in practice.

src/ui/components/ClaudeMdAltNamesView.tsx (1)

70-82: Stale closure on delete index adjustment.

After updateSettings removes an item, altNames still reflects the old state within this render cycle. The adjustment logic on lines 79-81 uses altNames.length - 1 (the pre-deletion length), which may set selectedIndex one position higher than intended.

For example, if you have 3 items and delete the last one (index 2), altNames.length - 1 is still 2, so selectedIndex >= 2 is true, and it gets set to Math.max(0, 3 - 2) = 1, which is correct. However, the logic is fragile if the timing changes.

Consider using the length after deletion for clarity:

♻️ Suggested improvement
     } else if (input === 'd') {
       // Delete
       if (altNames.length > 0) {
+        const newLength = altNames.length - 1;
         updateSettings(s => {
           if (!s.claudeMdAltNames) return;
           s.claudeMdAltNames = s.claudeMdAltNames.filter(
             (_, index) => index !== selectedIndex
           );
         });
-        if (selectedIndex >= altNames.length - 1) {
-          setSelectedIndex(Math.max(0, altNames.length - 2));
+        if (selectedIndex >= newLength) {
+          setSelectedIndex(Math.max(0, newLength - 1));
         }
       }

@bl-ue bl-ue merged commit b468508 into main Feb 3, 2026
2 checks passed
@bl-ue bl-ue deleted the agents-md-support branch February 3, 2026 22:43
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.

Feature Request: Support AGENTS.md. Feature: Support AGENTS.md

1 participant