Agent 规则

AGENTS.md 生成器

快速生成适合仓库的 AGENTS.md,写清楚构建、测试、代码风格、安全边界和最终回复要求。

Output AGENTS.md
Size 0 lines
Mode Template

中文说明

好的 Agent 指令文件应该短、具体、可执行。不要把整份文档塞进上下文,要告诉 Agent 应该读什么、运行什么、避免什么。

第一版中文页保留部分英文 API 字段、模型名和表单标签,方便和官方文档、价格表、开发工具配置项对应。计算结果只做预算和选型参考,最终价格、限额和条款以官方后台或服务商当前公开说明为准。

What belongs in AGENTS.md

Good agent instructions describe the repository, the commands that must run, the areas that should not be touched, and the verification expectations. They should not repeat the whole README or become a long style guide that every task has to carry.

What to avoid

  • Do not paste secrets, private URLs, tokens, or customer examples.
  • Do not include hundreds of lines of framework docs.
  • Do not add vague rules like "write clean code" without concrete checks.
  • Do not hide deployment or billing risks from the agent.

AGENTS.md vs CLAUDE.md vs Cursor rules

People searching for an AGENTS.md generator usually want one durable instruction file that keeps coding agents from repeating the same mistakes. The safest pattern is to make AGENTS.md the concise operational source of truth, then bridge tool-specific files to it when needed. That avoids maintaining three long, drifting instruction documents.

Codex has first-class AGENTS.md discovery. OpenAI's Codex documentation says it reads AGENTS.md files before work starts, layers global and project guidance, and lets closer files override broader ones. Claude Code uses memory files such as CLAUDE.md, and its documentation recommends using `/memory` to verify what loaded. Cursor uses project rules, commonly stored under `.cursor/rules`, and the older `.cursorrules` format has been treated as a legacy path in Cursor docs.

Tool Primary guidance file Best use Risk to avoid
Codex AGENTS.md and optional nested overrides. Repository commands, test expectations, deployment boundaries, and local conventions. Overly large files that hit instruction-size limits or conflict with deeper directory rules.
Claude Code CLAUDE.md, often importing or summarizing AGENTS.md. Small project memory, recurring corrections, model/workflow hints. Long stale memory files that consume context on every turn.
Cursor .cursor/rules/*.mdc or project rules. Scoped rules for frameworks, directories, test commands, and coding standards. A broad always-on rule set that makes every task carry irrelevant context.

Recommended AGENTS.md structure

A useful AGENTS.md should read like an internal runbook for an agent that can edit files. It should not be a marketing README, a full architecture book, or a copy of framework documentation. The generated template uses six sections because they map to the moments where agents need concrete direction: project context, commands, coding rules, safety/data rules, verification, and final response expectations.

  1. Project context: stack, app type, ownership boundaries, and where the important code lives.
  2. Commands: install, lint, test, build, local server, and deployment check commands.
  3. Coding rules: concrete local rules such as component patterns, API helpers, database migration policy, and formatting expectations.
  4. Safety and data: files or directories never to expose, secrets handling, production deployment rules, and billing-sensitive actions.
  5. Verification: what must be run for frontend, backend, docs, migrations, or generated assets.
  6. Final response: what the agent should report back, including changed files and checks run.

Examples by project type

For a static website or pSEO site, AGENTS.md should mention canonical URL rules, sitemap updates, analytics/ad placement constraints, and the public-only deploy directory. For a React or Next.js app, it should include package manager, build command, component conventions, route structure, and accessibility checks. For a backend, the file should make database migration, auth, secrets, and test fixture rules explicit. For a monorepo, keep the root file short and add path-scoped guidance near specialized packages.

The generator intentionally creates a compact file. If the output grows beyond a few hundred lines, split it. A root AGENTS.md can hold global rules, while `apps/web/AGENTS.md`, `services/billing/AGENTS.md`, or `.cursor/rules/frontend.mdc` can hold scoped rules. Smaller scoped rules are easier to keep current and less likely to pollute unrelated tasks.

Maintenance workflow

  • Add a rule only after the same correction happens more than once.
  • Remove rules that no longer match the codebase or CI pipeline.
  • Keep commands copied from package scripts or CI, not memory.
  • After changing stack, deployment, ads, analytics, billing, or auth, update AGENTS.md in the same pull request.
  • Ask the agent to list active instructions before a risky refactor so you can catch stale guidance early.

FAQ

Should I commit AGENTS.md?

For project-specific instructions, yes. Versioning the file keeps agent behavior aligned with code changes and lets teammates review changes to commands, safety rules, and verification policy.

Can AGENTS.md contain private deployment notes?

It can contain operational rules, but not secrets. Do not include API keys, cookies, account recovery details, private customer data, or anything that would be harmful if committed or accidentally deployed.

How long should AGENTS.md be?

Short enough that an agent can use it on every task. A practical root file is often 50-150 lines. If a rule only applies to one directory or framework, put it in a scoped file instead of the root.

Source notes

This generator is independent. Confirm exact file loading behavior in the coding agent you use because tools can differ in precedence and scope rules.