prompt-engineering

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Guidelines for creating and editing Coding Agent prompts (commands, agents, skills, context files).
Important: Always Read the detailed reference for the corresponding prompt type before starting work.
创建和编辑Coding Agent提示词(命令、Agent、Skill、上下文文件)的指南。
重要提示:开始工作前,请务必阅读对应提示词类型的详细参考文档。

Prompt Type Quick Reference

提示词类型速查

TypeLocationInvocationPurposeReference
Command
.claude/commands/<name>.md
/command-name
Reusable tasks for users
references/command.md
Agent
.{.super-agent,.claude}/agents/<name>.md
@agent-name
/ Task tool
Specialized subagents
references/agent.md
Skill`{.super-agent.claude.codex.github}/skills/<name>/SKILL.md`
Context File
.claude/CLAUDE.md
etc.
Auto-loadedAlways-needed project context
references/context-file.md
DocumentAnyManual referenceStandalone prompts-
Other references:
  • references/orchestration.md
    - Orchestrator design for calling subagents
  • references/permission-syntax.md
    - Permission syntax for allowed-tools
  • references/hooks.md
    - Lifecycle hook configuration
类型位置调用方式用途参考文档
Command(命令)
.claude/commands/<name>.md
/command-name
供用户复用的任务
references/command.md
Agent
.{.super-agent,.claude}/agents/<name>.md
@agent-name
/ 任务工具
专业子代理
references/agent.md
Skill`{.super-agent.claude.codex.github}/skills/<name>/SKILL.md`
Context File(上下文文件)
.claude/CLAUDE.md
自动加载项目必备的通用上下文
references/context-file.md
Document(文档)任意位置手动引用独立提示词-
其他参考文档:
  • references/orchestration.md
    - 调用子代理的编排器设计
  • references/permission-syntax.md
    - 允许工具的权限语法
  • references/hooks.md
    - 生命周期钩子配置

Core Principles

核心原则

1. Single Responsibility

1. 单一职责

Each prompt has one clear purpose.
  • ✅ Environment setup only / Code implementation only
每个提示词有且仅有一个明确的用途。
  • ✅ 仅环境搭建 / 仅代码实现

2. Independence from Caller

2. 与调用方解耦

Avoid references to "orchestrator" or "parent task"; focus on input/output contracts.
  • ✅ "Analyze the provided code and identify issues..."
避免提及“编排器”或“父任务”;专注于输入/输出约定。
  • ✅ “分析提供的代码并识别问题...”

3. Conciseness

3. 简洁性

Only information necessary for execution. Remove verbose examples, hypothetical paths, and generic patterns.
仅保留执行所需的信息。移除冗长示例、假设路径和通用模式。

4. Noise Avoidance

4. 避免冗余

  • Avoid examples in multiple languages (choose the primary language)
  • Avoid hypothetical file paths (CONTRIBUTING.md, etc.)
  • Omit detailed steps that the LLM can infer
  • 避免使用多语言示例(选择项目的主要语言)
  • 避免假设性文件路径(如CONTRIBUTING.md等)
  • 省略LLM可自行推导的详细步骤

Formatting Rules

格式规则

  • No h1 headings: Do not start with
    #
  • Language:
    description
    in the project's primary language; body can also be in primary language
  • XML tags: Use for structuring when there are multiple sections
  • 无一级标题:请勿以
    #
    开头
  • 语言
    description
    使用项目的主要语言;正文也可使用主要语言
  • XML标签:当存在多个章节时,使用XML标签进行结构化

Orchestration

编排

When calling subagents:
  1. Invocation template required: Include complete Task tool usage example
  2. Responsibility separation: Subagents should be generic; task-specific details go in templates
调用子代理时:
  1. 必须包含调用模板:提供完整的任务工具使用示例
  2. 职责分离:子代理应保持通用;任务特定细节放入模板中

Special Rules for Context Files

上下文文件的特殊规则

Be especially careful since they are always loaded:
  • 80% rule: Only information needed by 80% of tasks
  • Index-first: Reference details via pointers
  • Scrutinize commands: Only commands the LLM will autonomously execute
  • Target under 200 lines
由于上下文文件会被自动加载,需格外注意:
  • 80%规则:仅保留80%的任务所需的信息
  • 索引优先:通过指针引用详细内容
  • 严格审核命令:仅保留LLM可自主执行的命令
  • 目标行数控制在200行以内