用途:当用户想创建、重新生成或刷新 AI 编码代理(Copilot、Claude 等)的自定义指令时使用。它是 AgentRC「度量→生成→维护」循环中的生成步骤。
主要能力:生成多种指令文件。.github/copilot-instructions.md 为默认、全工作区常驻,适合 VS Code Copilot;AGENTS.md 适合多代理仓库;.github/instructions/*.instructions.md 按 applyTo glob 限定作用域,适合 monorepo 的分区或分语言规则;CLAUDE.md 通过 --claude-md 生成(仅嵌套策略)。支持 flat(默认,单文件)与 nested(中心文件加按主题拆分文件)两种策略。monorepo 可用 --areas、--area <name>、--areas-only 生成按区域限定的指令,区域在 agentrc.config.json 中定义。
使用方式:先选目标文件,默认 .github/copilot-instructions.md,仅在用户提到多代理/Claude/Cursor 时改用 AGENTS.md。除非用户已指定,否则询问 flat 或 nested。读取 agentrc.config.json 检测区域。先运行 dry-run 预览:npx -y github:microsoft/agentrc instructions --output <file> --strategy <flat|nested> [--areas|--area <name>] [--claude-md] --dry-run,确认后去掉 --dry-run(必要时加 --force)。若输出为 copilot-instructions.md 且为 nested,将 .agents/<topic>.md 改写为 .github/instructions/<topic>.instructions.md 并加 applyTo frontmatter;若用 --areas,则为每个区域写 .github/instructions/<area>.instructions.md,applyTo 取自区域 paths。区域文件命名用小写 kebab-case。
限制:AgentRC 读取实际代码而非模板;--claude-md 仅嵌套策略可用;VS Code 在活动文件匹配 applyTo 时自动应用 .instructions.md,根 copilot-instructions.md 始终加载;不要在 CI 中非交互运行,指令应通过 PR 合入。默认模型为 claude-sonnet-4.6。