Coding Prompt — AI 编程提示词最佳实践
Activate: 激活编程提示词 | 优化提示词 | improve my prompt
Purpose
This skill improves the quality of coding prompts sent to AI by diagnosing weaknesses,
applying proven principles, and proactively detecting common AI failure patterns during
active coding sessions.
Table of Contents
| Section | Content | Location |
|---|
| 1 | Prompt Diagnosis Checklist | INLINECODE0 |
| 2 |
Core Principles |
references/principles.md |
| 3 | Communication Patterns |
references/patterns.md |
| 4 | Workflow Templates |
references/templates.md |
| 5 | Anti-Pattern Quick Reference |
references/anti-patterns.md |
| 6 | Structural Wisdom |
references/structure.md |
| 7 | Evolution Protocol | Below (this file) |
How This Skill Works
This skill operates in two modes. Detailed rules are stored in references/ files — load them only when needed per the instructions below.
Mode 1: Explicit Optimization (100% reliable)
When explicit prompt optimization is requested — via trigger phrases, pasting a prompt for review, or prefacing an instruction with "优化提示词" — perform a full diagnosis and return a rewritten/improved version of the prompt.
Trigger phrases:
- -
优化提示词: <your prompt> — Rewrite the prompt following all principles - INLINECODE8 /
activate coding-prompt — Enter active mode - INLINECODE10 /
优化提示词 / INLINECODE12 - INLINECODE13 / INLINECODE14
Before starting diagnosis, load all reference files:
read_file(references/checklist.md)
read_file(references/principles.md)
read_file(references/patterns.md)
read_file(references/templates.md)
read_file(references/anti-patterns.md)
read_file(references/structure.md)
read_file(references/learnings.md)
Then run through the checklist and apply principles to rewrite the prompt.
Output format for optimization:
CODEBLOCK1
Mode 2: Active Monitoring (high-priority signals only)
Once activated (Mode 1 triggered), the skill remains active for the rest of the session. In this mode, proactively alert when only these high-priority signals are detected:
| Alert | Signal | Response |
|---|
| 🚨 Fake completion | D12 | AI claims "done" but code contains stubs/TODOs/placeholder returns/sample data. Append: INLINECODE15 |
| 🚨 Rule-based bias |
D11 | AI chooses hardcoded rules/regex/scoring when LLM-native would be better. Append:
[coding-prompt] ⚠️ 检测到规则匹配偏见:建议使用 LLM 原生能力替代硬编码 <具体规则>。 |
For all other signals (D1-D10): Do NOT proactively interrupt. Only mention them if explicitly asked for a prompt review.
Do NOT load reference files in Mode 2. The rules above are sufficient for proactive monitoring.
Session persistence note: Mode 2 relies on conversation context. If context degradation is suspected (~10+ turns without explicit reference to active monitoring), re-confirm active status before issuing alerts.
Golden rule: The user's original instruction always takes priority. Alerts and suggestions are additive, never overriding.
Evolution on demand: When the user says "更新技能" / "update skill", follow Section 7 below.
7. Evolution Protocol / 进化协议
Trigger: 更新技能 / update skill
Target: references/learnings.md ONLY
File Permission Matrix
| File | Permission | Reason |
|---|
| INLINECODE18 | 🔒 READ-ONLY | Constitution — defines the skill |
| INLINECODE19 |
🔒
READ-ONLY | Structural checklist — completeness over flexibility |
|
references/principles.md | 🔒
READ-ONLY | Axiom-level rules — universal best practices |
|
references/patterns.md | 🔒
READ-ONLY | Communication mechanics — objective patterns |
|
references/anti-patterns.md | 🔒
READ-ONLY | Curated reference — grow via learnings promotion |
|
references/templates.md | 🔒
READ-ONLY | Workflow structure — behavioral consistency |
|
references/structure.md | 🔒
READ-ONLY | Architecture wisdom — condensed condition→action |
|
references/learnings.md | ✅
APPEND-ONLY | Personal experience layer — the sole evolution target |
Rule: Any attempt to modify files outside learnings.md is a violation. Refuse and redirect to learnings.md.
Step 1: Review
Read references/learnings.md first to understand existing experience. Then analyze the current coding session for:
- - Patterns that worked well and are reusable (not one-off)
- Mistakes or pitfalls worth documenting as warnings
- Personal preferences or conventions discovered during collaboration
Filter criteria — only extract experiences that meet ALL of:
- 1. Reusable: applicable to future sessions, not specific to one task
- Non-redundant: not already covered by existing rules in SKILL.md or references/
- Actionable: can be stated as a clear rule or guideline
Step 2: Propose
Present a structured proposal in the format of learnings.md sections:
CODEBLOCK2
If a section has no content, omit it from the proposal.
Step 3: Confirm (MANDATORY)
Wait for explicit user confirmation before making ANY changes. This is the highest priority rule in this skill.
Step 4: Write to learnings.md
After confirmation:
- 1. Read current INLINECODE29
- Structure the new content to match existing format (consistent style, concise wording)
- Check if any new entry overlaps or supersedes an existing entry — if so, consolidate by updating the existing entry rather than adding a duplicate
- Append or update entries in the appropriate section
- Update the version number and "最后更新" date in the header
- Write the complete revised file
Anti-Bloat Guidelines
- - Architect-level refinement: Each entry must be distilled with the precision of a senior architect — abstract the pattern, not the incident. One insight per entry, no padding.
- Entry format: Each entry must be 2-4 lines max. No verbose narratives, no multi-paragraph case studies.
- Consolidation over accumulation: When a new entry overlaps an existing one, merge and refine rather than append. The goal is a growing body of wisdom, not a growing file.
- Style consistency: All entries must follow the same format as existing ones. Do not introduce new section types.
Coding Prompt — AI 编程提示词最佳实践
激活:激活编程提示词 | 优化提示词 | improve my prompt
目的
本技能通过诊断提示词弱点、应用经过验证的原则,并在活跃编程会话中主动检测常见的AI失败模式,从而提升发送给AI的编程提示词质量。
目录
| 章节 | 内容 | 位置 |
|---|
| 1 | 提示词诊断清单 | references/checklist.md |
| 2 |
核心原则 | references/principles.md |
| 3 | 沟通模式 | references/patterns.md |
| 4 | 工作流模板 | references/templates.md |
| 5 | 反模式速查 | references/anti-patterns.md |
| 6 | 结构智慧 | references/structure.md |
| 7 | 进化协议 | 下方(本文件) |
本技能如何运作
本技能以两种模式运行。详细规则存储在 references/ 文件中——仅按以下说明在需要时加载它们。
模式1:显式优化(100%可靠)
当通过触发短语、粘贴提示词以供审查,或在指令前加上优化提示词来请求显式提示词优化时,执行完整诊断并返回重写/改进后的提示词版本。
触发短语:
- - 优化提示词: <你的提示词> — 遵循所有原则重写提示词
- 激活编程提示词 / activate coding-prompt — 进入活跃模式
- improve my prompt / 优化提示词 / check my prompt
- prompt review / 提示词审查
开始诊断前,加载所有参考文件:
read_file(references/checklist.md)
read_file(references/principles.md)
read_file(references/patterns.md)
read_file(references/templates.md)
read_file(references/anti-patterns.md)
read_file(references/structure.md)
read_file(references/learnings.md)
然后运行诊断清单并应用原则重写提示词。
优化输出格式:
原始提示词
<用户的原始提示词>
诊断结果
- - D2 缺少约束:<缺少的内容>
- D4 缺少场景:<缺少的内容>
优化后的提示词
<应用改进后的重写提示词>
模式2:主动监控(仅高优先级信号)
一旦激活(触发模式1),该技能将在会话的剩余时间内保持活跃。在此模式下,仅当检测到以下高优先级信号时主动发出警报:
| 警报 | 信号 | 响应 |
|---|
| 🚨 假完成 | D12 | AI声称完成但代码包含桩代码/TODO/占位返回/示例数据。追加:[coding-prompt] ⚠️ 检测到假完成:代码包含 <具体问题>,请替换为真实实现。 |
| 🚨 基于规则的偏见 |
D11 | AI在LLM原生方式更优时选择硬编码规则/正则/评分。追加:[coding-prompt] ⚠️ 检测到规则匹配偏见:建议使用 LLM 原生能力替代硬编码 <具体规则>。 |
对于所有其他信号(D1-D10):不要主动打断。仅在明确要求提示词审查时提及它们。
不要在模式2中加载参考文件。 以上规则足以进行主动监控。
会话持久性说明:模式2依赖于对话上下文。如果怀疑上下文退化(约10轮以上未明确提及主动监控),在发出警报前重新确认活跃状态。
黄金法则:用户的原始指令始终优先。警报和建议是附加性的,绝不覆盖。
按需进化:当用户说更新技能/update skill时,遵循下方第7节。
7. 进化协议
触发:更新技能 / update skill
目标:仅限 references/learnings.md
文件权限矩阵
| 文件 | 权限 | 原因 |
|---|
| SKILL.md | 🔒 只读 | 宪法——定义技能 |
| references/checklist.md |
🔒
只读 | 结构清单——完整性优先于灵活性 |
| references/principles.md | 🔒
只读 | 公理级规则——通用最佳实践 |
| references/patterns.md | 🔒
只读 | 沟通机制——客观模式 |
| references/anti-patterns.md | 🔒
只读 | 精选参考——通过学习提升来增长 |
| references/templates.md | 🔒
只读 | 工作流结构——行为一致性 |
| references/structure.md | 🔒
只读 | 架构智慧——浓缩的条件→行动 |
| references/learnings.md | ✅
仅追加 | 个人经验层——唯一的进化目标 |
规则:任何修改 learnings.md 以外文件的尝试都是违规行为。拒绝并重定向到 learnings.md。
步骤1:审查
首先读取 references/learnings.md 以了解现有经验。然后分析当前编程会话,寻找:
- - 运行良好且可复用的模式(非一次性)
- 值得作为警告记录的错误或陷阱
- 协作过程中发现的个人偏好或约定
筛选标准——仅提取满足所有条件的经验:
- 1. 可复用:适用于未来会话,不特定于单一任务
- 非冗余:未被 SKILL.md 或 references/ 中的现有规则覆盖
- 可操作:可以表述为清晰的规则或指南
步骤2:提议
以 learnings.md 章节的格式呈现结构化提案:
经验沉淀提案
被验证有效的模式
-
规则:<具体做法,一句话>
-
触发场景:<什么情况下适用>
-
来源:<本次会话的什么具体情况>
反模式(踩过的坑)
-
表现:
- 预防:<在prompt中加什么约束>
- 来源:<本次会话的具体情况>
个人偏好
- 规则:<具体偏好描述>
如果某个章节没有内容,则从提案中省略。
步骤3:确认(强制)
在进行任何更改之前,等待用户明确确认。 这是本技能中优先级最高的规则。
步骤4:写入 learnings.md
确认后:
- 1. 读取当前 references/learnings.md
- 结构化新内容以匹配现有格式(风格一致,措辞简洁)
- 检查是否有任何新条目与现有条目重叠或取代——如果是,通过更新现有条目而非添加重复条目进行合并
- 在相应章节追加或更新条目
- 更新头部版本号和最后更新日期
- 写入完整的修订后文件
防膨胀指南
- - 架构级精炼:每个条目必须以高级架构师的精度进行提炼——抽象模式,而非事件。每条一个洞见,不填充内容。
- 条目格式:每个条目最多2-4行。无冗长叙述,无多段落案例研究。
- 合并优于积累:当新条目与现有条目重叠时,合并并精炼而非追加。目标是不断增长的智慧体系,而非不断增长的文件。
- 风格一致性:所有条目必须遵循与现有条目相同的格式。不要引入新的章节类型。