Self Documented Code 标志

Self Documented Code

社区
marekkirejczyk
self-documented-code

Rename everything in a scope (a repository, a PR, a directory, a concept) so each name explains itself and each concept has one name, keep comments only for what code cannot say, and update the project's glossary to match. Semantics, lint and tests stay intact.

概览

发布者marekkirejczyk
代码仓库skills
技能名称self-documented-code
星标数
157
复刻数
1
附带文件
1
许可协议MIT
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 1 个附带文件

    模型执行任务时可读取的脚本、模板和参考资料。这些文件为只读文件,绝不会被执行。

  • 开源

    由 marekkirejczyk 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Self Documented Code AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/marekkirejczyk/skills/tree/main/skills/self-documented-code
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/marekkirejczyk/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/self-documented-code .claude/skills/self-documented-code
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Self Documented Code,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Self Documented Code。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Self Documented Code 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Self-documented code

Rename the code in a scope so that every name says what it means and the same thing has the same name everywhere, and leave comments only for what the code cannot say. Arguments: $ARGUMENTS. If your agent does not fill that in, take them from the user's message.

The scope is what the user names: the repository, a PR or branch (only the names and comments that PR adds or changes, plus whatever must change with them), a directory, a file, a module, or a concept ("everything about payments"). With no scope given, use the whole repository.

Run from start to finish without asking for approval. The one stop is a failing baseline (rule 2).

Goal

A reader who sees only a name, at the place it is used, knows what it holds or does, without opening its definition or reading a comment.

You are done when all four hold:

  1. Every name is self-explanatory. Every variable, parameter, function, method, class, type, field, constant, file and test helper in scope has been reviewed, and renamed if it falls short of the naming standard.
  2. Every concept has one name. Across the scope, one concept has one term, and one term means one concept.
  3. Every comment earns its place. Each comment left in scope meets the comment standard.
  4. Every project dictionary matches the code. Each glossary or word list the project keeps uses the final terms (see Dictionaries).

Rules

These hold after every round. A round that breaks one is undone.

  1. Semantics stay the same. Same answers, errors, writes and calls, in the same order. Change only names, comments and dictionaries: logic, control flow, parameter order and the formatting of unrelated code stay as they are.
  2. Lint, type checks, build and tests pass, using the project's own commands. They must pass before you start: if they fail, stop and report it.
  3. Tests change only in names and comments. Their assertions, expected values and logic stay exactly as they are.
  4. External contracts keep their names. That covers anything code outside this repository depends on, or that is stored or sent: published package exports, public API routes and fields, database tables and columns, serialized keys, event names, environment variables, config keys, CLI flags, and names required by a framework or interface you don't own. Report a bad name of this kind and leave it.
  5. Every reference moves with its name. Use the language server's or compiler's rename where there is one. Then search for what tools can't see: strings, reflection, dynamic lookups, templates, mocks, docs, comments, scripts and CI config.
  6. Stay in scope. A rename may spread beyond the scope only when the code would otherwise break, and the report lists it. Dictionaries are updated wherever they live.

Naming standard

A name is good when:

  • It states meaning, not type or mechanics: unpaidInvoices, not list or invoiceArray.
  • It uses the domain's words, and the language's own conventions for case and idiom.
  • Its abbreviations are universal in the domain or language (id, url, i as the index of a short loop). Spell out the rest.
  • It carries its unit or qualifier when that matters: timeoutSeconds, priceInPence, isExpired, hasPaid.
  • A function says what it does and returns: a verb phrase for an action, a noun or question for a query. A function with a side effect sounds like one.
  • Its length tracks how far it travels: short in a three-line lambda, full for an export. Drop words the context already gives (order.orderId → order.id).
  • Every word carries meaning. data, info, manager, helper, util, temp, foo and a 2 suffix go, unless the word truly is the meaning.
  • It is true. It describes all of what the code does today.

A name that already meets the standard stays: rename for meaning, never for taste.

Comment standard

Code says what happens. A comment exists only for what a reader could not work out from well-named code:

  • Why this and not the obvious alternative: a decision, a trade-off, an approach that was tried and failed.
  • A non-trivial fact the code can't show: a vendor's undocumented behaviour, a workaround and its cause, an ordering constraint, a performance or security reason, a link to the issue or spec behind it.

Delete every other comment: one that narrates the code, restates a name or signature, labels a section, or holds dead code. Before deleting one, check whether it says something the code doesn't. If it does, move that into a name, or keep only that part as a why comment. Correct any comment you keep that the code contradicts.

New comments are rare: write one only for something you learned that a name cannot carry and this standard calls for.

Linter and compiler directives, licence headers, and doc comments that generate published documentation stay as they are.

Dictionaries

A dictionary is any place the project defines its words: GLOSSARY.md, a domain or ubiquitous-language doc, a terms section in the docs, a spell-check word list (cspell, codespell). Search for them before the vocabulary step. A project with none stays with none.

A dictionary's term is the default for its concept. When you choose a different one, or split or merge terms, change the entry in the same round as the rename: the new term, an accurate definition, the retired word gone. Add an entry for each domain concept the dictionary should have but lacks. Historical records such as ADRs and changelogs keep the words of their time.

Method

  1. Baseline. On a new branch, run lint, type checks, build and tests, and record the results. Done when all pass.
  2. Vocabulary. Read the scope and the dictionaries, and write a table: each concept, the names it has today, the one term it will use. Include each term with several meanings, and how it splits. Done when every name in scope maps to a row or is marked as already good.
  3. Rename in rounds. One concept or one module per round, outermost names first, with its dictionary entries. After each round run the checks, then commit. If a check goes red, undo the round and take a smaller step. Leave the branch unpushed. Done when every row of the table is applied.
  4. Comments. Now that the names are done, apply the comment standard across the scope, in a round of its own, so the new names can replace what the comments said.
  5. Sweep. Go through the scope once more, file by file, against both standards. Done when you have opened every file in scope, no old term from the table remains in the code or the dictionaries, and all checks pass.

When a name reveals a problem

A name that can't be made honest usually means the code does two things or is wrong. Leave the code as it is, give it the most accurate name you can, and report it.

Report

  • The vocabulary table, the number of names reviewed and renamed, and the number of comments deleted, rewritten and kept.
  • The dictionary entries changed, added and removed, or that the project has no dictionary.
  • Check results before and after.
  • Renames that went beyond the scope.
  • External names left alone that should change, with where they are defined.
  • Code the naming exposed as misleading, buggy or doing too much.

附带文件

技能加载后,模型会按需读取这些文件。它们仅作为可读文件提供,绝不会被执行。

常见问题

Self Documented Code AI 技能有什么作用?

Rename everything in a scope (a repository, a PR, a directory, a concept) so each name explains itself and each concept has one name, keep comments only for what code cannot say, and update the project's glossary to match. Semantics, lint and tests stay intact.

为什么在 TypingMind 中使用 Self Documented Code?

因为您只需安装一次,就能搭配任何模型使用。Self Documented Code 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Self Documented Code?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/marekkirejczyk/skills/tree/main/skills/self-documented-code。TypingMind 会读取其中的 SKILL.md,打包相关文件,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Self Documented Code?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Self Documented Code 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Self Documented Code 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Self Documented Code AI 技能免费吗?

是的。marekkirejczyk 已在 GitHub 上根据 MIT 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇