跳到正文
Skillpedia
通用编程7.1k · #13523

coding-guidelines

它能做什么

这个技能为 AI 在编写或修改代码时设定行为准则。它要求 AI 说明假设、保持方案简单,并且只改动任务所需的部分。适合希望 AI 编写的代码谨慎、专注的任何人。

适用场景

  • ✓当 AI 为功能或缺陷修复编写、修改或审查代码时。
  • ✓当你注意到 AI 添加了你没有要求的功能或抽象时。
  • ✓当你希望代码改动保持较小,并与现有风格相符时。

技能链接

https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(development)/coding-guidelines/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(development)/coding-guidelines/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请修复这个缺陷,但保持改动很小,不要触碰无关的代码;如果你对任何事情不确定,请告诉我。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能要求 AI 提出其中的假设,选择可行的最简单方案,并进行与现有风格相符的精准编辑。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Coding Guidelines

Behavioral guidelines to reduce common LLM coding mistakes. These principles bias toward caution over speed—for trivial tasks, use judgment.

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

Before implementing:

  • State assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them—don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.
  • Disagree honestly. If the user's approach seems wrong, say so—don't be sycophantic.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

When editing existing code:

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it—don't delete it.

When your changes create orphans:

  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Transform tasks into verifiable goals:

  • "Add validation" → "Write tests for invalid inputs, then make them pass"
  • "Fix the bug" → "Write a test that reproduces it, then make it pass"
  • "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:

1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]

Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.

常见问题

它适用于架构或文档吗?

不适用。它面向代码任务,而不是架构设计或文档编写。

它会阻止 AI 提问吗?

不会。它鼓励在事情不清楚时提问。

它也适用于简单的任务吗?

这些准则倾向于谨慎,AI 会对简单任务进行判断。

详情

作者的原始描述

Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, modifying, or reviewing code — implementation tasks, code changes, refactoring, bug fixes, or feature development. Do NOT use for architecture design, documentation, or non-code tasks.

repo: tech-leads-club/agent-skills

热度

GitHub 星标
7.1k
排名
#13523
许可证
—
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能