如何让 CLAUDE.md 指向 AGENTS.md 而不重复维护两份规则?
把跨工具共享的命令、架构和硬边界放进 AGENTS.md,再把 CLAUDE.md 精简为包含 @AGENTS.md(Claude Code 原生导入语法)和 Claude 专属说明的薄适配层;macOS/Linux 也可用 ln -s AGENTS.md CLAUDE.md。
把共享项目规则从 CLAUDE.md 迁移到跨工具标准 AGENTS.md(适配 Codex CLI、Cursor、Copilot),同时自动生成轻量 @AGENTS.md 指针与 AgentLint 实时体检分。
# Acme Billing API Node 22 + TypeScript REST service handling Stripe webhooks, idempotent ledger writes, and PDF invoices. ## Commands - Fast single test: `npx vitest run src/billing/webhook.test.ts` - Full test suite: `pnpm test` - Typecheck & lint: `npx tsc --noEmit && pnpm lint` - Build: `pnpm build` ## Rules - Don't bypass Zod validation on webhook routes. Instead parse payloads in `src/webhooks/schema.ts`. Because unvalidated retries previously caused duplicate charges. - Don't mix package managers. Instead use `pnpm` exclusively. Because competing lockfiles break CI caching. - When changing SQL schemas, read `docs/migrations.md` before editing Prisma files. ## Continuity - Record verified test outputs in `HANDOFF.md` before ending multi-step sessions.
| 文件 | 读取工具 | 推荐放什么 | 同步策略 |
|---|---|---|---|
| AGENTS.md | Codex CLI, Cursor, Copilot, Windsurf | 项目事实、构建/测试命令、包管理器约束、架构与安全边界 | 唯一真源 |
| CLAUDE.md | Claude Code | @AGENTS.md 导入 + .claude/settings.json hooks、skills、权限说明 | @AGENTS.md |
| .cursor/rules/*.mdc | Cursor Agent & Inline Edit | 带 globs: 的按目录/文件类型局部规范(UI、SQL、测试等) | 按 glob 挂载 |
| .github/copilot-instructions.md | GitHub Copilot | 指向 AGENTS.md 或同步后的精简仓库规范 | 指针 / CI 校验 |
| GEMINI.md | Gemini CLI | @AGENTS.md 导入 + Gemini 专属工具提示 | @AGENTS.md |
把跨工具共享的命令、架构和硬边界放进 AGENTS.md,再把 CLAUDE.md 精简为包含 @AGENTS.md(Claude Code 原生导入语法)和 Claude 专属说明的薄适配层;macOS/Linux 也可用 ln -s AGENTS.md CLAUDE.md。
不要。Codex CLI、Cursor、Copilot 不会执行 .claude/settings.json 钩子。将它们保留在 CLAUDE.md 中可以避免误导其他工具。
不会。格式转换与 AgentLint 实时体检 100% 在本地浏览器运行,零上传、零追踪。
直接复制 TypeScript、Python、Next.js、FastAPI、Rust、Go、Vue、Monorepo 高分起步模板。
查看中位数 132 行、37 个超 40K 截断案例与 58% Actions 未锁 SHA 的全量数据。
看 VS Code、Next.js、uv、Bun 等顶级开源项目的 CLAUDE.md / AGENTS.md 实测评分。