新闻详情

新闻详情

首页 / 资讯中心 / 详情

Claude Code 插件 Agent 的 AI 辅助生成:agent-creation-prompt 模板与实战指南

发布时间:2026/10/1 1:17:07来源:尧图网络
Claude Code 插件 Agent 的 AI 辅助生成:agent-creation-prompt 模板与实战指南
AI 插件开发工具插件系统【免费下载链接】claude-plugins-officialOfficial, Anthropic-managed directory of high quality Claude Code Plugins.项目地址https://gitcode.com/GitHub_Trending/cl/claude-plugins-official点击查看免费下载导读本文讲解 claude-plugins-official 仓库中 plugin-dev 插件所内置的「AI 辅助 Agent 生成模板」agent-creation-prompt.md只需用一句话描述你需要的 Agent 能力就能让 Claude 依据官方 Agent 创建系统提示词自动产出包含identifier、whenToUse、systemPrompt三要素的 JSON 配置再转换为标准的agents/identifier.md文件。读完本文你将掌握完整的四步生成流程、三个可复用的生产级示例代码审查、测试生成、文档撰写、让生成质量显著提升的提示词写法以及用仓库自带脚本校验与迭代生成结果的方法从而为你的 Claude Code 插件快速创建可靠、可自主触发的 Agent。一、模板的定位从一句话需求到标准 Agent 文件在 plugin-dev 的 agent-development 技能中创建 Agent 有两种方法Method 1AI 辅助生成AI-Assisted Generation——使用本文讲解的模板把需求描述喂给 Claude由 Claude 生成完整配置Method 2手动创建Manual Creation——人工按照 frontmatter 字段与系统提示词结构逐项编写。该模板的完整说明位于 agent-creation-prompt.md其配套的生成系统提示词位于 agent-creation-system-prompt.md。从源码结构看这套模板与 plugin-dev 内置的agent-creatorAgentagent-creator.md共享同一套设计理念提炼核心意图 → 设计专家人格 → 构建完整指令 → 优化性能 → 生成标识符 → 编写触发描述。使用模板的核心前提是在向 Claude 发送生成请求前先加载或让 Claude 加载Agent 创建系统提示词。这样 Claude 才会按照规定的 JSON 结构和触发描述格式进行输出而不是自由发挥。二、四步使用流程从描述到落地文件Step 1描述你的 Agent 需求在动手之前先想清楚四个问题What task should the agent handle?——Agent 具体要完成什么任务When should it be triggered?——它应该在什么时机被触发Should it be proactive or reactive?——是需要主动触发Proactive助手在完成任务后自主调用还是被动触发Reactive用户显式请求时调用What are the key responsibilities?——它的核心职责有哪些这四问对应的是 agent-creation-system-prompt.md 中「Extract Core Intent」的要求识别根本目的、关键职责与成功标准既要看显式需求也要捕捉隐含需求。Step 2使用生成提示词将以下内容发送给 Claude确保 agent-creation-system-prompt 已加载Create an agent configuration based on this request: [YOUR DESCRIPTION] Return ONLY the JSON object, no other text.将[YOUR DESCRIPTION]替换为你在 Step 1 中整理好的需求描述。「Return ONLY the JSON object」这条约束很重要它要求 Claude 严格返回可解析的 JSON避免混入解释性文字方便后续直接提取字段。可参考 SKILL.md 中给出的完整生成提示模式含 5 条 Requirements 说明信息量更完整。Step 3Claude 返回 JSONClaude 会返回包含三个字段的 JSON 对象{ identifier: agent-name, whenToUse: Use this agent when... Typical triggers include [scenario 1], [scenario 2], and [scenario 3]. See \When to invoke\ in the agent body for worked scenarios., systemPrompt: You are...\n\n## When to invoke\n\n- **[Scenario A].** [Description]\n- **[Scenario B].** [Description]\n\n**Your Core Responsibilities:**... }三个字段的格式约定来自 agent-creation-system-prompt.mdidentifier唯一、描述性的标识符只允许小写字母、数字和连字符通常是 2~4 个单词用连字符连接如code-reviewer、api-docs-writer、test-generator要能清晰表达主功能、便于记忆输入避免helper、assistant这类泛化词whenToUse平铺散文flat prose单行书写。标准句式是Use this agent when [conditions]. Typical triggers include [scenario 1], [scenario 2], and [scenario 3]. See When to invoke in the agent body for worked scenarios.systemPrompt完整的 Agent 行为系统提示词用第二人称You are...、You will...书写开头必须包含一个 When to invoke 小节用散文项目符号列出 2~4 个触发场景每个场景以加粗的短场景名开头后面跟对情境与应对动作的散文描述随后是人格、职责、流程、输出格式与边界情况。关于触发场景的写作有一条关键红线在 triggering-examples.md 中有专门强调不要用带引号的用户原话transcript 形状开头而应描述用户所处的情境。例如用The user has just implemented a feature (often spanning several files) and asks whether everything looks good. Run a review of the recent diff and report findings.而不是把user: Can you check if everything looks good?这种对话记录写进场景里。同时要尽量同时覆盖主动触发与被动触发两种场景。Step 4转换为 Agent 文件创建agents/[identifier].md将 JSON 中的字段映射到 YAML frontmatter 与正文--- name: [identifier from JSON] description: [whenToUse from JSON] model: inherit color: [choose: blue/cyan/green/yellow/magenta/red] tools: [Read, Write, Grep] # Optional: restrict tools --- [systemPrompt from JSON]各 frontmatter 字段的取值规则详见 SKILL.md字段必填取值/格式说明name是小写字母、数字、连字符3~50 字符首尾必须为字母数字Agent 标识符用于命名空间与触发description是平铺散文以 Use this agent when... 开头最关键字段Agent 注册时会被加载进上下文供路由决策必须包含触发条件、2~4 个典型场景的散文摘要、以及对正文 When to invoke 的指引model是inherit/sonnet/opus/haiku推荐inherit与父级同模型除非有特定模型能力需求color是blue/cyan/green/yellow/magenta/redUI 视觉标识蓝/青分析审查绿生成黄校验警告红安全关键品红创作重构tools否工具名数组如[Read, Write, Grep]省略则拥有全部工具最佳实践是按最小权限原则只给必要工具常见工具组合只读分析用[Read, Grep, Glob]代码生成用[Read, Write, Grep]测试执行用[Read, Bash, Grep]完全权限则省略该字段或写[*]。三、实战示例 1代码审查 AgentCode Review Agent你的请求Your requestI need an agent that reviews code changes for quality issues, security vulnerabilities, and adherence to best practices. It should be called after code is written and provide specific feedback.Claude 生成的结果Claude generates{ identifier: code-quality-reviewer, whenToUse: Use this agent when the user has written code and needs quality review, or explicitly asks to review code changes. Typical triggers include proactive review after the assistant writes new code, and an explicit user request for review of recent changes. See \When to invoke\ in the agent body for worked scenarios., systemPrompt: You are an expert code quality reviewer specializing in identifying issues in software implementations.\n\n## When to invoke\n\n- **Proactive review after new code.** The assistant has just written or modified code (e.g. an authentication feature). Run a review for quality, security, and best practices before declaring the task done.\n- **Explicit review request.** The user asks for the recent changes to be reviewed for issues. Run a thorough review and report findings.\n\n**Your Core Responsibilities:**\n1. Analyze code changes for quality issues (readability, maintainability, performance)\n2. Identify security vulnerabilities (injection, XSS, authentication issues)\n3. Check adherence to project best practices and coding standards\n4. Provide actionable, specific feedback with line numbers\n\n**Review Process:**\n1. Read the code changes using available tools\n2. Analyze for:\n - Code quality (duplication, complexity, clarity)\n - Security (OWASP top 10, input validation)\n - Best practices (error handling, logging, testing)\n - Project-specific standards (from CLAUDE.md)\n3. Identify issues with severity (critical/major/minor)\n4. Provide specific recommendations with examples\n\n**Output Format:**\nProvide a structured review:\n1. Summary (2-3 sentences)\n2. Critical Issues (must fix)\n3. Major Issues (should fix)\n4. Minor Issues (nice to fix)\n5. Positive observations\n6. Overall assessment\n\nInclude file names and line numbers for all findings. }你创建的 Agent 文件You create文件路径agents/code-quality-reviewer.md--- name: code-quality-reviewer description: Use this agent when the user has written code and needs quality review, or explicitly asks to review code changes. Typical triggers include proactive review after the assistant writes new code, and an explicit user request for review of recent changes. See When to invoke in the agent body for worked scenarios. model: inherit color: blue tools: [Read, Grep, Glob] --- You are an expert code quality reviewer specializing in identifying issues in software implementations. ## When to invoke - **Proactive review after new code.** The assistant has just written or modified code (e.g. an authentication feature). Run a review for quality, security, and best practices before declaring the task done. - **Explicit review request.** The user asks for the recent changes to be reviewed for issues. Run a thorough review and report findings. **Your Core Responsibilities:** 1. Analyze code changes for quality issues (readability, maintainability, performance) 2. Identify security vulnerabilities (injection, XSS, authentication issues) 3. Check adherence to project best practices and coding standards 4. Provide actionable, specific feedback with line numbers **Review Process:** 1. Read the code changes using available tools 2. Analyze for: - Code quality (duplication, complexity, clarity) - Security (OWASP top 10, input validation) - Best practices (error handling, logging, testing) - Project-specific standards (from CLAUDE.md) 3. Identify issues with severity (critical/major/minor) 4. Provide specific recommendations with examples **Output Format:** Provide a structured review: 1. Summary (2-3 sentences) 2. Critical Issues (must fix) 3. Major Issues (should fix) 4. Minor Issues (nice to fix) 5. Positive observations 6. Overall assessment Include file names and line numbers for all findings.可以对照 complete-agent-examples.md 中code-reviewer的生产级完整版本其审查流程细化为 Gather Context用 Glob 找最近修改文件、Read Code、质量分析DRY、复杂度、错误处理、日志、安全分析注入、认证授权、输入校验、硬编码密钥、最佳实践、按严重度分类、生成报告七个步骤并补充了「问题过多时按类型分组、优先列出 Top 10」「无问题时的正向确认」「大变更集先聚焦最影响文件」等边界情况处理——这些正是从模板生成后可以继续打磨的方向。四、实战示例 2测试生成 AgentTest Generation Agent你的请求Create an agent that generates unit tests for code. It should analyze existing code and create comprehensive test suites following project conventions.Claude 生成的结果{ identifier: test-generator, whenToUse: Use this agent when the user asks to generate tests, needs test coverage, or has written code that needs testing. Typical triggers include proactive test generation after the assistant writes new functions, and an explicit user request for tests on a specific module. See \When to invoke\ in the agent body., systemPrompt: You are an expert test engineer specializing in creating comprehensive unit tests.\n\n## When to invoke\n\n- **Proactive coverage after new code.** The assistant has just implemented new functions (e.g. user authentication functions) without tests. Generate a comprehensive test suite before declaring the task done.\n- **Explicit test request.** The user asks for tests on a specific surface. Generate the requested suite following project conventions.\n\n**Your Core Responsibilities:**\n1. Analyze code to understand behavior\n2. Generate test cases covering happy paths and edge cases\n3. Follow project testing conventions\n4. Ensure high code coverage\n\n**Test Generation Process:**\n1. Read target code\n2. Identify testable units (functions, classes, methods)\n3. Design test cases (inputs, expected outputs, edge cases)\n4. Generate tests following project patterns\n5. Add assertions and error cases\n\n**Output Format:**\nGenerate complete test files with:\n- Test suite structure\n- Setup/teardown if needed\n- Descriptive test names\n- Comprehensive assertions }你创建的 Agent 文件agents/test-generator.md采用与上面示例相同的结构frontmatter systemPrompt。生产级版本见 complete-agent-examples.md为测试生成 Agent 选了color: green生成/成功导向与tools: [Read, Write, Grep, Bash]需要执行测试并在质量标准中补充了 DAMP 原则Descriptive And Meaningful Phrases、测试独立性无共享状态、避免过度 Mock、AAAArrange-Act-Assert结构等约束——生成模板时可把这些要求写进你的需求描述中。五、实战示例 3文档撰写 AgentDocumentation Agent你的请求Build an agent that writes and updates API documentation. It should analyze code and generate clear, comprehensive docs.结果Agent 文件采用api-docs-writer标识符description为散文式触发描述覆盖新增 API 面后的主动文档生成与显式文档请求两类场景正文包含 When to invoke 小节。文档类的生产级完整模板同样在 complete-agent-examples.md 中docs-generatorcolor: cyantools: [Read, Write, Grep, Glob]其生成流程为分析代码理解公开接口/参数/返回值/错误条件 → 识别既有文档模式Markdown/JSDoc、风格、示例组织→ 生成内容 → 按项目约定格式化 → 校验准确性与完整性。六、让生成质量跃升的四个提示词技巧模板提供了四类经过验证的提示词增强手段1. 需求描述要具体Be Specific in Your Request模糊写法VagueI need an agent that helps with code具体写法SpecificI need an agent that reviews pull requests for type safety issues in TypeScript, checking for proper type annotations, avoiding any, and ensuring correct generic usage2. 明确触发偏好Include Triggering Preferences告诉 Claude Agent 应在何时激活尤其要说明是否需要主动触发Create an agent that generates tests. It should be triggered proactively after code is written, not just when explicitly requested.3. 带上项目上下文Mention Project Context生成结果会参考 CLAUDE.md 中的项目规范因此在描述中带上技术栈与约定Create a code review agent. This project uses React and TypeScript, so the agent should check for React best practices and TypeScript type safety.4. 定义输出期望Define Output Expectations明确输出的形式与粒度Create an agent that analyzes performance. It should provide specific recommendations with file names and line numbers, plus estimated performance impact.更深层的生成规则可参考 agent-creation-system-prompt.md 中的定制化建议安全类 Agent 追加 OWASP Top 10 检查与输入净化校验测试类 Agent 追加 AAA 模式与测试隔离文档类 Agent 追加语言简洁性与项目文档标准要求。另外注意其作用域约定审查类 Agent 默认审查最近编写的代码而非整个代码库除非用户明确说明——这个假设建议直接写进需求描述。七、生成后的校验用 validate-agent.sh 把关模板要求生成后必须校验Validation After Generation# Validate structure ./scripts/validate-agent.sh agents/your-agent.md # Check triggering works # Test with realistic invocation phrasings仓库实际提供了该校验脚本位于 validate-agent.sh其检查项与判定标准如下文件结构文件必须存在且以---开头、存在第二个---闭合 frontmattername字段必填必须匹配^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$首尾为字母数字仅含字母、数字、连字符长度 3~50 字符helper、assistant、agent、tool等泛化名称会触发警告description字段必填建议 10~5000 字符应包含example触发示例块应以 Use this agent when... 开头这些是警告级别脚本并不会因此失败model字段必填合法值为inherit、sonnet、opus、haikucolor字段必填合法值为blue、cyan、green、yellow、magenta、redtools字段可选有值则回显省略视为拥有全部工具系统提示词不能为空最短 20 字符、超 10000 字符告警应使用第二人称You are/You will/Your建议包含 responsibilities/process 与 output 格式定义。脚本按 error_count 与 warning_count 汇总结果无错误且无警告输出All checks passed!有警告无错误仍算通过exit 0有错误则失败exit 1。八、迭代改进生成只是起点如果生成的 Agent 需要改进按以下循环操作识别问题——找出缺失或错误的地方手动编辑 Agent 文件——聚焦四个优化点改进description:与 When to invoke 中触发场景的命名更贴切、覆盖更全让系统提示词更具体让流程步骤更清晰定义更好的输出格式重新校验再次运行 validate-agent.sh再次测试用真实场景验证触发与行为。关于触发的调试triggering-examples.md 给出了三类常见问题的定位思路Agent 不触发——检查description:是否命名了正确的场景、正文场景是否覆盖用户实际措辞、是否有更具体的竞争 Agent 抢走了路由触发过于频繁——场景过于泛化或缺少何时不要用的边界说明可添加Do not invoke when...行在错误场景触发——重写场景使其与 Agent 实际能力匹配。场景数量建议为最少 2 个通常一个显式 一个主动推荐 3~4 个最多不超过 5 个。九、AI 辅助生成的优势与手动编辑的取舍模板总结了 AI 辅助生成的四个核心优势Comprehensive全面Claude 会自动纳入边界情况与质量检查Consistent一致遵循经过验证的模式不同 Agent 间风格统一Fast快速秒级产出远快于手动撰写Complete完整提供完整的系统提示词结构无需从零搭建。但以下情况建议手动编辑生成结果需要非常特定的项目模式如特定框架约定需要自定义工具组合想要独特的人格或风格需要与既有 Agent 集成需要精确的触发条件。最佳实践是先用生成起步再手动精修Start with generation, then refine manually for best results。十、在 plugin-dev 生态中的完整衔接这份模板并非孤立文件而是 plugin-dev 插件开发工具包的一部分核心技能入口agent-development/SKILL.md——承载 Agent 文件结构、frontmatter 全字段、系统提示词设计、验证规则等完整知识生成系统提示词agent-creation-system-prompt.md——本文模板所依赖的底层生成提示词原文触发最佳实践triggering-examples.md——description:与 When to invoke 的写法规范与调试指南系统提示词设计模式system-prompt-design.md——分析、生成、校验、编排四类 Agent 的提示词模板以及篇幅建议标准 Agent 约 1000~2000 词避免超过 10000 词生产级完整示例complete-agent-examples.md——四个可直接改用的完整 Agent审查、测试、文档、安全自动化执行者agent-creator.md——把上述流程封装成 Agent 本身model: sonnet、color: magenta、tools: [Write, Read]用户说出需求后它会自动生成 Agent 文件并给出配置摘要与测试建议端到端工作流create-plugin.md 的 8 阶段插件创建流程中Phase 5 组件实现阶段会加载 agent-development 技能并使用 agent-creator 生成 AgentPhase 6 用 plugin-validator 与 validate-agent.sh 统一校验Phase 7 用真实场景测试触发。十一、总结AI 辅助生成 Agent 的本质是用一套经过官方沉淀的结构化系统提示词把编写高质量 Agent这一复杂任务转化为描述需求 校验落地两步。核心要点可归结为描述要具体——任务、触发时机、主动/被动、职责四要素齐全并带上项目上下文与输出期望严格遵循 JSON 三字段结构——identifier命名规范、whenToUse平铺散文、systemPrompt内含 When to invoke 散文场景列表生成后必须校验与迭代——用validate-agent.sh把关结构用真实措辞测试触发针对不触发/过触发/错触发三类问题定向修复生成与手写互补——用生成的全面性与一致性做起点用手动精修补足项目特定模式、工具组合与触发精度。按照本模板产出的 Agent 文件放入插件的agents/目录后即被自动发现无需额外注册配置可直接随插件分发使用。赞分享AI 插件开发工具插件系统【免费下载链接】claude-plugins-officialOfficial, Anthropic-managed directory of high quality Claude Code Plugins.项目地址https://gitcode.com/GitHub_Trending/cl/claude-plugins-official点击查看免费下载相关推荐claude-plugins-official 实战用 agent-creation-system-prompt 驱动 Claude Code 插件 Agent 的自动生成claude plugins official 实战用 agent creation system prompt 驱动 Claude Code 插件 AgenAI 插件开发工具插件系统用 Claude Code 自定义加密货币价格检查 Agent从 Agent Prompt 模板到 Slash Command 实战用 Claude Code 自定义加密货币价格检查 Agent从 Agent Prompt 模板到 Slash Command 实战 在 Claude Codprompts.chat Claude Code 插件深度解析prompt-manager Agent 如何用 MCP 工具管理 AI Prompt 库prompts.chat Claude Code 插件深度解析prompt manager Agent 如何用 MCP 工具管理 AI Prompt 库 本文人工智能AI 应用提示工程前端后端创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
网站建设高端定制企业官网
RELATED

相关资讯

更多精彩内容,欢迎继续阅读

较早相关资讯

最新相关资讯

Oracle升级再遇ORA-20001?详解XDB XML inventory的定位与修复 2026/10/1 4:03:01

Oracle升级再遇ORA-20001?详解XDB XML inventory的定位与修复

升级 Oracle 时再次撞上 ORA-20001?这次盯紧 XDB 的 XML inventory前阵子帮客户做 12.1 到 19c 的数据库升级,中途在 alert 日志里看到了那个让我非常熟悉又头疼的错误:ORA-20001: Latest xml inventory is not loaded into table。升级脚本在…

阅读更多 →
扣子编程构建英语教学AI闭环:从课堂到工作流的实战落地 2026/10/1 4:03:01

扣子编程构建英语教学AI闭环:从课堂到工作流的实战落地

1. 这不是“写个网页”,而是重构英语教学的底层逻辑扣子编程搭建英语学科全流程智能教学网页AI应用——这个标题里藏着三个被严重低估的关键信息:“扣子”不是工具选择,而是开发范式切换;“英语学科”不是内容标签,而是…

阅读更多 →
Jev 统一密钥管理与模型路由:AI 编程工具配置实战指南 2026/10/1 4:03:00

Jev 统一密钥管理与模型路由:AI 编程工具配置实战指南

1. 全网刷屏的 Jev 到底是个什么东西最近技术圈里讨论度最高的话题之一,就是 Jev。不管你是刷技术社区、看群聊记录,还是翻各种工具推荐帖,几乎都能看到有人在问“Jev 怎么用”“Jev 密钥怎么申请”“Jev 和 Claude Code 怎么配合”。我一开始…

阅读更多 →
Nginx启动、重启与常用命令全解析:进程模型、信号机制与生产避坑 2026/10/1 4:03:00

Nginx启动、重启与常用命令全解析:进程模型、信号机制与生产避坑

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

阅读更多 →
昇腾平台RAG索引结构优化:选型、调参与实战指南 2026/10/1 4:03:00

昇腾平台RAG索引结构优化:选型、调参与实战指南

三个月前我在昇腾Atlas 800上把一套RAG知识库跑起来,检索平均耗时110ms,Top10命中率只有55%。排查完整个RAG SDK链路,真正拖后腿的既不是Embedding模型也不是生成模型,而是检索前的索引结构——这也是我决定把昇腾平台RAG SDK检索…

阅读更多 →
Spring Boot内嵌Tomcat原理与配置实战:从端口调优到避坑指南 2026/10/1 4:02:54

Spring Boot内嵌Tomcat原理与配置实战:从端口调优到避坑指南

我常被问到一个很基础但很多人没真正搞懂的问题:Tomcat干嘛的?更准确地说,Spring Boot项目里那个"内嵌Tomcat"到底是什么,它和单独下载安装的Tomcat有什么关系,为什么明明可以在应用里直接启动,却…

阅读更多 →

今日资讯

本周资讯

本月资讯

看完文章仍有疑问?

联系尧图顾问,获取一对一建站咨询

立即免费咨询 📞 400-888-8888
📞 ✉