Borrowing it
Nothing to install: this file belongs to MisonL/Ling. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/MisonL/Ling/main/.agents/skills/clean-code/SKILL.mdgit clone --depth 1 https://github.com/MisonL/LingWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/misonl/ling/clean-code)<a href="https://agentmods.dev/skills/misonl/ling/clean-code"><img src="https://agentmods.dev/badge/skills/misonl/ling/clean-code/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/misonl/ling/clean-code"><img src="https://agentmods.dev/badge/skills/misonl/ling/clean-code.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00031 | $0.02190 |
| Opus 5.5 | $0.00012 | $0.00876 |
| Sonnet 5.5 | $0.00006 | $0.00438 |
| Haiku 4.5 | $0.00003 | $0.00219 |
Grade A, and why
clean-code scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 211 lines — stays where its author put it; the contents beside it link to each section on GitHub.
整洁代码 - 务实的 AI 编码标准
Clean Code(整洁代码)是核心技能—— 保持简洁、直接并专注于解决方案。
核心原则
| 原则 | 规则 |
|---|---|
| SRP | 单一职责(Single Responsibility)—— 每个函数/类只做一件事 |
| DRY | 不要重复(Don't Repeat Yourself)—— 提取重复项并复用 |
| KISS | 保持简单(Keep It Simple)—— 采用能跑通的最简单方案 |
| YAGNI | 你不会需要它(You Aren't Gonna Need It)—— 不构建未被要求的功能 |
| Boy Scout | 离开时让代码比你来时更整洁 |
命名规则
| 元素 | 规范 |
|---|---|
| 变量(Variables) | 揭示意图:userCount 而非 n |
| 函数(Functions) | 动词 + 名词:getUserById() 而非 user() |
| 布尔值(Booleans) | 提问形式:isActive, hasPermission, canEdit |
| 常量(Constants) | SCREAMING_SNAKE:MAX_RETRY_COUNT |
准则: 如果需要注释解释命名,请直接重命名。
函数规则
| 规则 | 描述 |
|---|---|
| 短小(Small) | 最多 20 行,理想 5-10 行 |
| 专注(One Thing) | 只做一件事,并把它做好 |
| 层次(One Level) | 每个函数只包含一个抽象层级 |
| 参数少(Few Args) | 最多 3 个参数,优先 0-2 个 |
| 无副作用(No Side Effects) | 不要产生预期之外的输入状态改变 |
代码结构
| 模式 | 应用建议 |
|---|---|
| 卫语句(Guard Clauses) | 针对边缘情况及早返回 |
| 扁平化优先(Flat > Nested) | 避免深度嵌套(最多 2 层) |
| 组合(Composition) | 将短小函数组合使用 |
| 就近原则(Colocation) | 相关代码尽量放近 |
AI 编码风格
| 场景 | 行动建议 |
|---|---|
| 用户要求功能 | 直接编写实现 |
| 用户报告问题 | 修复,不做多余解释 |
| 需求不明确 | 先询问,不做假设 |
反模式(Anti-Patterns)
| [FAIL] 错误模式 | [OK] 推荐修复 |
|---|---|
| 每一行都写注释 | 删除显而易见的注释 |
| 为单行逻辑封装 helper | 直接内联 |
| 为 2 个对象写工厂模式 | 直接实例化 |
| 只有 1 个函数的 utils.ts | 代码放在被使用处 |
| “First we import...” | 直接写代码 |
| 深度嵌套 | 使用卫语句 |
| 使用魔术数字 | 使用具名常量 |
| 万能函数 | 按职责拆分 |
[CRITICAL] 编辑任何文件前(先思考)
修改文件前先问自己:
| 提问 | 为什么 |
|---|---|
| 谁引用了这个文件? | 修改可能会破坏它们 |
| 这个文件引用了谁? | 接口可能需要变更 |
| 有哪些测试覆盖了这里? | 测试可能会失败 |
| 这是共享组件吗? | 可能影响多个地方 |
快速检查:
File to edit: UserService.ts
+-- Who imports this? -> UserController.ts, AuthController.ts
+-- Do they need changes too? -> Check function signatures
[CRITICAL] 准则: 同一任务内同时编辑该文件与所有受影响的依赖文件。 [CRITICAL] 禁止: 遗留断裂引用或缺失更新。
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 1mo ago First seen · 211 lines · 31 tokens per session scan A fd97018c5767
clean-code is a skill published in the GitHub repository MisonL/Ling (8 stars, last pushed 7mo ago), licensed MIT. It adds 31 tokens to every session and 2,190 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
local-ai-agents
Build local-first AI agents that run entirely on a developer workstation with Microsoft Foundry Local and Qwen function-calling models. Covers Small Language Models (SLMs), the OpenAI-compatible local endpoint, sandboxed local tools, local RAG with Chroma, local MCP servers, hybrid cloud/local routing, and the…
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.
next-cache-components-adoption
Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…
chat-pet-sprite-creation
Use when creating or changing VS Code chat pet sprite art, sprite sheets, state animations, eye treatments, Stable/Insiders variants, or pet transitions under src/vs/workbench/contrib/chat/browser/widget/media/chatPet.
cpu-profile-analysis
Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…
insight-error-page
Write or audit an insight-kind error page for the Next.js dev overlay. Use when creating a new errors/ .mdx page, auditing an existing one, or checking that a page matches the framework fix cards. Covers page structure, title alignment, FixCard cards with Copy prompt button, code snippets, terminology verification…