good-code

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Design Principles — Agent Skill

代码设计原则 — Agent Skill

You are setting up agent instructions for this project based on the 6 Principles of Good Code Design: Consistent, Correct, Clear, Concise, Simple, Salient.
你正在基于优秀代码设计六大原则:一致性、正确性、清晰性、简洁性、简单性、显著性为当前项目设置Agent指令。

Step 1: Check for Existing Files

步骤1:检查现有文件

Before writing anything, check if any of these files already exist in the project root:
  • CLAUDE.md
  • AGENTS.md
  • .cursorrules
  • .github/copilot-instructions.md
If any exist, show the user what was found and ask whether to:
  • Merge the principles into the existing file
  • Replace the existing file
  • Cancel
Do not overwrite without explicit confirmation.
编写任何内容前,请先检查项目根目录下是否已存在以下文件:
  • CLAUDE.md
  • AGENTS.md
  • .cursorrules
  • .github/copilot-instructions.md
如果存在任意上述文件,请向用户展示已找到的文件,并询问用户需要执行的操作:
  • 合并:将设计原则合并到现有文件中
  • 替换:覆盖现有文件
  • 取消:终止操作
未经用户明确确认,不得覆盖原有文件。

Step 2: Detect Project Stack

步骤2:检测项目技术栈

Scan the project root for configuration files to determine the stack:
FileStack
package.json
Node.js / TypeScript / JavaScript
tsconfig.json
TypeScript
pyproject.toml
Python (modern)
setup.py
/
setup.cfg
Python (legacy)
Cargo.toml
Rust
go.mod
Go
Gemfile
Ruby
pom.xml
/
build.gradle
Java / Kotlin
mix.exs
Elixir
Package.swift
Swift
Also detect:
  • Package manager: Look for
    uv.lock
    ,
    poetry.lock
    ,
    pnpm-lock.yaml
    ,
    yarn.lock
    ,
    package-lock.json
    ,
    Pipfile.lock
  • Test framework: Look for
    pytest.ini
    ,
    jest.config.*
    ,
    vitest.config.*
    ,
    .mocharc.*
    , test directories
  • Linter/formatter: Look for
    .eslintrc.*
    ,
    biome.json
    ,
    ruff.toml
    ,
    .prettierrc.*
    ,
    rustfmt.toml
扫描项目根目录下的配置文件,判断项目使用的技术栈:
文件技术栈
package.json
Node.js / TypeScript / JavaScript
tsconfig.json
TypeScript
pyproject.toml
Python (现代版本)
setup.py
/
setup.cfg
Python (旧版本)
Cargo.toml
Rust
go.mod
Go
Gemfile
Ruby
pom.xml
/
build.gradle
Java / Kotlin
mix.exs
Elixir
Package.swift
Swift
同时还要检测以下内容:
  • 包管理器:查找是否存在
    uv.lock
    poetry.lock
    pnpm-lock.yaml
    yarn.lock
    package-lock.json
    Pipfile.lock
  • 测试框架:查找是否存在
    pytest.ini
    jest.config.*
    vitest.config.*
    .mocharc.*
    以及测试目录
  • Linter/格式化工具:查找是否存在
    .eslintrc.*
    biome.json
    ruff.toml
    .prettierrc.*
    rustfmt.toml

Step 3: Read the Template

步骤3:读取模板

Read the
CLAUDE.md
file located in this skill's directory (next to this SKILL.md file). This is the base template you will customize. For the full rationale behind each principle, see
PRINCIPLES.md
in the same directory.
读取本skill目录下(与当前SKILL.md文件同目录)的
CLAUDE.md
文件,这是你要进行自定义的基础模板。如需了解每条原则背后的完整逻辑,请查看同目录下的
PRINCIPLES.md
文件。

Step 4: Generate the Instructions File

步骤4:生成指令文件

Using the template from Step 3, create a
CLAUDE.md
(or
AGENTS.md
if the user's agent platform prefers it) in the project root. The template includes Python and TypeScript as examples — adapt the language-specific sections to match the detected stack:
  1. Style Guide — Replace the Python/TypeScript subsections with idiomatic style entries for the detected language(s).
  2. Project Setup — Replace with actual setup instructions: package manager commands, build/test/lint scripts found in the project's config files (
    package.json
    scripts,
    Makefile
    ,
    pyproject.toml
    , etc.). The Python section in the template shows the level of detail expected.
使用步骤3获取的模板,在项目根目录下创建
CLAUDE.md
(如果用户的Agent平台偏好AGENTS.md则生成该文件)。模板中默认包含Python和TypeScript作为示例,请根据检测到的技术栈调整语言相关的章节内容:
  1. 风格指南:将示例中的Python/TypeScript小节替换为检测到的编程语言的惯用风格规范条目
  2. 项目设置:替换为实际的项目设置指令:包括从项目配置文件(
    package.json
    脚本、
    Makefile
    pyproject.toml
    等)中识别到的包管理器命令、构建/测试/lint脚本。模板中的Python章节展示了需要达到的细节程度。

Step 5: Confirm

步骤5:确认

After writing the file, tell the user:
  • What file was created and where
  • What stack was detected
  • What sections were customized
  • Suggest they review and adjust the Project Setup section for any project-specific tooling
生成文件后,告知用户以下信息:
  • 创建了什么文件、存储路径是什么
  • 检测到的技术栈是什么
  • 自定义了哪些章节
  • 建议用户审阅并调整项目设置章节,适配所有项目专属的工具