用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/alyraffauf/chezmoi --skill readable-code命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | readable-code |
| description | Readable, maintainable code standards. Use when writing source code. |
Readability first. Code is read far more often than it is written. Write for the human who opens this file six months from now, or six minutes from now, with no context.
Names are the primary interface for understanding code.
customerAddress not custAddr.i/j for loop indices in C-style languages, e for error in Go, T for type parameters in generics). When in doubt, spell it out.currentNode not curr; previousValue not prev; result not res; answer not ans.generationTimestamp not gen_ts.By type: variables = noun phrase (activeUserCount, processedLines); functions = verb+noun (findUserByEmail, calculateTotalPrice); booleans = question form (isActive, hasPermission, canEdit, shouldRetry); constants = SCREAMING_SNAKE_CASE (MAX_RETRY_COUNT, DEFAULT_TIMEOUT_MS); collections = plural noun (users, pendingOrders); predicates/filters = past participle or adjective (enabledFeatures, matchedRecords).
Rule: If you need a comment to explain a name, rename it.
Functions — under 40 lines (don't artificially split one clear responsibility just to hit the count); one responsibility and one abstraction level per function; 0–2 args ideal (3 acceptable, 4+ → struct/object with named fields); no hidden side effects (checkUserStatus must not also update the database); guard clauses / return early; no clever one-liners (prefer explicit multi-step logic over dense expressions); extract a meaningful chunk when you can, but inline a one-liner used only once.
Code structure — guard clauses (return early for nulls/errors/edge cases); flat over nested (max 2 levels visual nesting); step-down rule (high-level functions first, helpers below); colocation (keep related code close, don't scatter one concept across files); whitespace as paragraph punctuation within a function; named constants not magic numbers (MAX_RETRIES not 3).
Solve today's problem with tomorrow's load in mind.
Scale — YAGNI (no abstractions for hypothetical requirements); scalable boundaries (interfaces, data models, and failure modes that grow without rewrites); config over hardcode (timeouts, limits, feature flags, URLs, thresholds); loose coupling (a change in one module shouldn't cascade); fail loudly, recover cleanly (silent failures become catastrophic at scale); keep observability easy to add (logs, metrics, tracing); wrap third-party deps so they can be replaced or mocked.
The code is the explanation. Comments are the apology.
Do not state the obvious.
❌ // increment counter by 1
counter += 1;
✅ counter += 1;
Do not write tutorials in comments. Assume the reader knows the language. Explain why a non-obvious choice was made, not what the syntax does.
Do not leave commented-out code. Delete it. Git remembers.
Use simple, direct clauses in comments. Prefer imperative style. Write Retry on timeout not This will retry the operation if a timeout occurs. Comments should be brief and to the point.
Do document surprises. If the code must diverge from an obvious approach for a subtle reason, a brief comment is warranted.
Stop and think.
| Question | Why it matters |
|---|---|
| What imports this file? | Signatures changes may break callers. |
| What does this file import? | Changing an interface may require downstream updates. |
| What tests cover this? | Tests will fail if behavior changes. |
| Is this shared code? | A change here affects many places. |
Rule: Edit the file AND all dependent files in the same task. Never leave broken imports, missing updates, or orphaned references.
| Situation | Action |
|---|---|
| User asks for a feature | Write it directly and clearly. Consider how it fits the existing architecture. |
| User reports a bug | Fix it. Do not explain the fix unless asked. Check if the root cause affects other areas. |
| No clear requirement | Ask, do not assume. |
| Multiple valid approaches | Choose the most readable and the one that respects existing boundaries, not the most impressive. |
| User asks about architecture or design | Explain tradeoffs concisely. Recommend the approach that minimizes future maintenance burden and cognitive load, not the most novel. |
| Encountering messy existing code | Follow the Boy Scout rule: leave it cleaner. But do not refactor unrelated code without permission. |
| Performance vs. readability tension | Default to readability. Optimize only when there is measurable evidence of a bottleneck, not on speculation. |
Before reporting a task complete, verify:
i/j/e/T are fine; no curr, prev, res, tmp).MAX_RETRIES not 3).if.Rule: If any check fails, fix it before completing.