Agent skill

General Coding Best Practices

by davidYichengWei in davidYichengWei/agentic-engineering-framework

A checklist of language-neutral rules for writing and reviewing code: naming, function design, control flow, resource safety, comments and logging.

MITAuto-check passedDevelopment

SKILL.md written in Chinese; this summary is our English description.

Install General Coding Best Practices

skills CLI
$ npx skills add davidYichengWei/agentic-engineering-framework --skill bp-coding-best-practices -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install davidYichengWei/agentic-engineering-framework bp-coding-best-practices --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/davidYichengWei/agentic-engineering-framework.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/bp-coding-best-practices .claude/skills/bp-coding-best-practices && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
bp-coding-best-practices
GitHub stars
158
Token cost
~631 tokens
SKILL.md length
136 words
Files
3
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

A checklist of language-neutral rules for writing and reviewing code: naming, function design, control flow, resource safety, comments and logging.

  • Works in 3 steps: 识别:在函数开头找所有"获取但需要交还"的东西 → 对照:找一个功能相似的现有返回路径,逐行对比它处理了哪些资源 → 分类:这个新路径是成功、失败、还是新的第三种状态?现有 ownership…
  • Reviewing a change for naming, nesting and function-size problems
  • SKILL.md covers 命名, 函数设计, 控制流 and 资源安全, plus 3 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

This skill collects general coding rules to apply while writing or reviewing code. Naming rules call for self-explanatory names, named constants instead of magic numbers, question-style booleans and names whose length matches their scope. Function rules ask for a single responsibility and compact parameter lists, with const correctness for parameters that are not modified. Control flow favors guard clauses and early returns over deep nesting.

The resource-safety section covers RAII, explicit ownership and narrow variable scopes, and gives a check for new return paths: list every contract resource acquired at function entry, such as callbacks, locks, reference counts, transactions or registered objects, and compare against an existing path so nothing is left unreleased or untriggered. Comments should explain why rather than what, and logging guidance covers key branches, log levels and minimal context. Two detail files expand on readability and safety.

When your agent uses it

  • Reviewing a change for naming, nesting and function-size problems
  • Adding a new early-return path and checking that locks and callbacks are handled
  • Deciding what to log and at which level in a new code path

Example prompts

  • “Review this function against the coding best practices and point out nesting and naming issues.”
  • “I added an early return in the request handler. Check that every lock and callback is still handled.”
  • “Suggest log statements for the error and fast-return branches in this module.”

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. 识别:在函数开头找所有"获取但需要交还"的东西
  2. 对照:找一个功能相似的现有返回路径,逐行对比它处理了哪些资源
  3. 分类:这个新路径是成功、失败、还是新的第三种状态?现有 ownership 注释是否覆盖?

What it can do on your machine

Read from SKILL.md and the folder at commit 1f7ac0f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

General Coding Best Practices loads about 631 tokens when it runs. Until then it costs about 20 tokens; SKILL.md has 136 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~20
When it runs · the whole SKILL.md, loaded when a task matches
~631

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from davidYichengWei/agentic-engineering-framework at commit 1f7ac0f, republished under its MIT licence (© davidYichengWei). 136 words, ~631 tokens.

Download SKILL.mdSave it as .claude/skills/bp-coding-best-practices/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
bp-coding-best-practices
description
通用编码最佳实践。在编写或 review 代码时使用。涵盖可读性、命名、函数设计、控制流、资源安全、注释规范。

通用编码最佳实践

设计原则(SOLID、设计模式):参见 bp-component-design Skill 特定语言/模块规范:参见相应的 standards skills


命名

原则说明
自解释retryCount 而非 n
无魔法数字const int SECONDS_IN_DAY = 86400;
布尔命名isValid, hasAccess(问题形式)
作用域匹配小作用域可短(i),大作用域要描述性

函数设计

原则说明
单一职责一个函数做一件事;名字需要 "And" 说明做太多了
参数精简超过 3-4 个参数 → 考虑结构体封装
const 正确不修改的参数标 const,防止意外修改

控制流

Guard Clause:失败情况先处理并返回,主逻辑保持左对齐

Early Return:显式采用 early return 编程范式,尽量将可 early return 的检查前置。

cpp
// ❌ 深层嵌套
if (order != nullptr) {
    if (order->isValid()) {
        if (order->hasItems()) {
            // main logic
        }
    }
}

// ✅ Guard Clause
if (order == nullptr) return;
if (!order->isValid()) return;
if (!order->hasItems()) return;
// main logic (not nested)

资源安全

原则说明
RAII资源生命周期绑定对象生命周期,避免手动清理分散在多条路径
所有权显式区分 owner 与 borrower,避免隐式转移所有权
窄作用域变量声明靠近首次使用,减少悬空与误用概率

跨语言场景统一要求:新增分支/返回路径时,必须检查资源契约是否闭环(释放类资源 + 触发类资源)。

新增返回路径的契约检查

当新增 return、early exit 或新分支时,必须逐一检查函数入口处获取的所有"契约性资源"。

契约性资源:函数持有但不拥有、需要在特定时机交还/触发的资源:

  • Closure/Callback(需要 Run)
  • 锁(需要 Unlock)
  • 引用计数(需要 Release)
  • 事务上下文(需要 Commit/Rollback/清理)
  • 幂等标记/Nonce(需要 Complete)
  • 注册到外部管理器的对象(需要 Remove/Unregister)

检查方法:

  1. 识别:在函数开头找所有"获取但需要交还"的东西
  2. 对照:找一个功能相似的现有返回路径,逐行对比它处理了哪些资源
  3. 分类:这个新路径是成功、失败、还是新的第三种状态?现有 ownership 注释是否覆盖?
❌ 反例✅ 正例
新分支只清理了数据结构,忘了 callback 的执行契约对照已有的 early return 路径,发现它调用了 callback->Run(),新路径也需要
假设"返回成功后调用方会处理 closure"检查调用方逻辑,确认 closure 执行责任的真实归属
只关注"要释放什么",忽略"要触发什么"同时检查释放类资源(锁、内存)和触发类资源(回调、事件)

注释

场景做法
何时写仅当意图不明显时;复杂算法;公共 API
写什么Why(为什么这样做),不是 What(做了什么)
TODO包含上下文和负责人
cpp
// ❌ 复述代码
// Increment i by 1
++i;

// ✅ 解释意图
// Skip index 0 because it is the sentinel slot.
for (size_t i = 1; i < slots.size(); ++i) { ... }

可观测性(日志)

场景做法
关键分支覆盖至少覆盖无数据快速返回、异常状态转换、错误返回三个分支
级别选择DEBUG 记录成功路径和排障上下文,WARN 记录异常但可恢复路径,ERROR 记录失败路径
上下文信息日志中携带最小必要上下文(如 request_id、key、error_code),避免无上下文日志

进阶

© davidYichengWei, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in skills/bp-coding-best-practices of davidYichengWei/agentic-engineering-framework.

  • SKILL.md
  • reference/readability.md
  • reference/safety.md

Open the folder on GitHubat commit 1f7ac0f

Compare with similar skills

General Coding Best Practices next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

General Coding Best Practices compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
General Coding Best Practices this skilldavidYichengWei/agentic-engineering-framework158—~631Automated safety check: PassMIT
WooCommerce Code Reviewwoocommerce/woocommerce11k3 repos~1.1kAutomated safety check: PassCustom licence
Skill Doli Code ReviewDolibarr/dolibarr7.7k1 repos~1.1kAutomated safety check: PassMIT
Dignified Python Standardsdocling-project/docling69k—~1.5kAutomated safety check: PassApache-2.0
Clean Code GuardamElnagdy/guard-skills1.3k2 repos~4.3kAutomated safety check: PassMIT
Archify Reviewtt-a1i/archify79k—~415Automated safety check: PassMIT

Similar skills

  • WooCommerce Code Review

    woocommerce/woocommerce

    Reviews WooCommerce code changes against the project's standards, flagging backend PHP architecture, naming, documentation, data integrity and testing violations.

    11k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Skill Doli Code Review

    Dolibarr/dolibarr

    Reviews Dolibarr PHP code for compliance with coding standards and security best practices, and fixes identified issues.

    7.7k GitHub starsUsed in 1 repo~1.1k tokens
    DevelopmentAuto-check passed
  • Dignified Python Standards

    docling-project/docling

    Applies opinionated production Python conventions chosen by the project's Python version: modern type syntax, pathlib, explicit checks and interface guidance.

    69k GitHub stars~1.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Clean Code Guard

    amElnagdy/guard-skills

    Reviews generated or changed production code against Clean Code, SOLID, DRY, KISS, YAGNI and LLM-specific failure modes before it ships, in any language.

    1.3k GitHub starsUsed in 2 repos~4.3k tokens
    DevelopmentAuto-check passed
  • Archify Review

    tt-a1i/archify

    Review Archify issues, PRs, or code through value, cost, and impact to support evidence-based maintenance decisions. Use for issue triage, change reviews, and…

    79k GitHub stars~415 tokensUpdated today
    DevelopmentAuto-check passed
  • Code Review Skill

    awesome-skills/code-review-skill

    Provides comprehensive code review guidance for React 19, Vue 3, Angular 17+, Svelte 5, Rust, TypeScript, Java, Java 8, PHP, Ruby, Rails, Python, Django, FastAPI, Go, C/.NET, Kotlin, Swift, Dart…

    2.1k GitHub stars~2.8k tokensUpdated 1 mo ago
    DevelopmentAuto-check: notes

More from davidYichengWei/agentic-engineering-framework

All 14 skills in this repo
  • Architecture Design Principles

    davidYichengWei/agentic-engineering-framework

    Gives architecture design principles for system design discussions and code review: module boundaries, dependency direction, data ownership and interface rules, plus a checklist.

    158 GitHub stars~545 tokensUpdated 6 mo ago
    Auto-check passed
  • Component Design Principles

    davidYichengWei/agentic-engineering-framework

    Chinese-language checklists for component-level design: class and module structure, public interfaces, data models, concurrency and error handling.

    158 GitHub stars~1k tokensUpdated 6 mo ago
    Auto-check passed
  • Skill Authoring Guide (Chinese)

    davidYichengWei/agentic-engineering-framework

    Chinese-language guide to writing and improving SKILL.md files: frontmatter rules, concise writing, progressive disclosure, common patterns and a pre-release checklist.

    158 GitHub stars~788 tokensUpdated 6 mo ago
    Auto-check passed
  • Self-Refinement from Corrections

    davidYichengWei/agentic-engineering-framework

    Turns mistakes you correct into proposed updates to persistent Rules and Skills so the same error does not recur in later sessions, triggered automatically or with /reflect.

    158 GitHub stars~575 tokensUpdated 6 mo ago
    Auto-check passed
  • Root-Cause Troubleshooting

    davidYichengWei/agentic-engineering-framework

    Diagnoses compile errors, runtime exceptions, failing tests, pipeline failures and production alerts from code and logs, giving a root cause before any fix.

    158 GitHub stars~646 tokensUpdated 6 mo ago
    Auto-check passed
  • Workflow Code Generation

    davidYichengWei/agentic-engineering-framework

    代码文件修改的统一入口。当用户请求任何代码变更(新功能、优化、Bug 修复、重构)时必须首先调用此 skill。仅适用于代码文件(如 .cc/.cpp/.h/.go/.py 等),修改 .md 等非代码文件时不需要调用。它会评估复杂度、检查 spec.md、生成 tasks.md、并逐个任务执行。

    158 GitHub stars~733 tokensUpdated 6 mo ago
    Auto-check passed

Categories

Questions about General Coding Best Practices

What does General Coding Best Practices do?

A checklist of language-neutral rules for writing and reviewing code: naming, function design, control flow, resource safety, comments and logging. This skill collects general coding rules to apply while writing or reviewing code. Naming rules call for self-explanatory names, named constants instead of magic numbers, question-style booleans and names whose length matches their scope.

When should I use General Coding Best Practices?

General Coding Best Practices fits situations like: reviewing a change for naming, nesting and function-size problems; adding a new early-return path and checking that locks and callbacks are handled; deciding what to log and at which level in a new code path.

How do I install General Coding Best Practices in Claude Code?

Run `npx skills add davidYichengWei/agentic-engineering-framework --skill bp-coding-best-practices -a claude-code`. Or copy the skill folder (skills/bp-coding-best-practices in davidYichengWei/agentic-engineering-framework) into .claude/skills/bp-coding-best-practices in your project. Claude Code loads it when a task matches its description.

How do I install General Coding Best Practices in Codex?

Run `npx skills add davidYichengWei/agentic-engineering-framework --skill bp-coding-best-practices -a codex`. Or copy the skill folder (skills/bp-coding-best-practices in davidYichengWei/agentic-engineering-framework) into .agents/skills/bp-coding-best-practices in your project. Codex loads it when a task matches its description.

Can I use General Coding Best Practices in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add davidYichengWei/agentic-engineering-framework --skill bp-coding-best-practices -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/bp-coding-best-practices, .gemini/skills/bp-coding-best-practices, .github/skills/bp-coding-best-practices and .opencode/skills/bp-coding-best-practices in your project.

What does General Coding Best Practices need to run?

SKILL.md names no scripts, command-line tools or credentials: General Coding Best Practices is instructions for the agent only.

Does General Coding Best Practices access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is General Coding Best Practices safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does General Coding Best Practices use?

General Coding Best Practices is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does General Coding Best Practices use?

About 631 tokens (SKILL.md is roughly 2.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to General Coding Best Practices?

Skills that share tags, products or a category with General Coding Best Practices: WooCommerce Code Review (woocommerce/woocommerce, 11k stars), Skill Doli Code Review (Dolibarr/dolibarr, 7.7k stars), Dignified Python Standards (docling-project/docling, 69k stars) and Clean Code Guard (amElnagdy/guard-skills, 1.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains General Coding Best Practices?

davidYichengWei (a GitHub user) maintains it in davidYichengWei/agentic-engineering-framework, which has 158 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on March 25, 2026.

Source: davidYichengWei/agentic-engineering-framework on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.