文件卫生
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 文档
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
在`.forge/docs-policy.md`中,每个存储库顶级的自述文件契约:对于每个具有> 5个文件的子目录:一个自述文件回答“这里有什么,为什么在这里,谁拥有它”。
规则:解释为什么,而不是解释什么。坏(什么) · 好(为什么) `// increment i` · `// skip the sentinel row at index 0` `// loop over users` · `// fan-out concurrency capped at 5 to respect upstream rate limit` `// returns null` · `// returns null when the user has been soft-deleted; callers must filter`
每个文档都包含: 顶部的上次更新日期(或“` footer) Code links that resolve at HEAD (use permalinks to `main”,而不是提交哈希) - 如果链接 404,CI 失败 范围声明 - 该文档涵盖的内容,不涵盖的内容 所有者 - 负责保持其最新状态的个人或团队
在 `.forge/docs-policy.md` 中: 公共文档 — 面向用户、营销级、版本化(端点文档的交叉引用 `api-design`) 内部文档 — 面向工程、存储库内、允许假设上下文(`CONTRIBUTING.md`、ADR、运行手册) 机密文档 — 凭证、客户数据、财务 — 从未在存储库中 每个文档都有一个横幅,指示其层级。
关注 保留变更日志:每个用户可见的变更一个条目,按 `Added`、`Changed`、`Deprecated`、`Removed`、`Fixed`、`Security` 分组。带有 `BREAKING:` 前缀的重大更改。重构不会获得条目,除非它们影响性能、安全性或行为。 *在进行更改的 PR 中更新*,而不是在发布时更新。
CI 作业每周运行: 检查每个内部链接解析 检查每个外部链接返回 2xx 标记任何上次更新时间 > 180 天的文档,其中链接代码自此以来发生了更改 标记任何早于 90 天的 TODO
# Documentation Hygiene
## Overview
Define the project's documentation contract — what gets documented, where it lives, how it stays current — *before* docs rot. Output is `.forge/docs-policy.md`: README standard per repo and subdirectory, in-code comment policy (WHY not WHAT), doc-rot prevention rules (dates, code links, generated docs), public-vs-internal doc split, and changelog discipline. Pairs with `code-review-and-quality` (review enforces the policy) and `shipping-and-launch` (CHANGELOG updated per release).
## When to Use
- A repo is older than 3 months and the README hasn't been touched since the first commit
- Subdirectories have grown to 5+ files with no entry-point doc
- In-code comments are mostly restating the code instead of explaining intent
- A new contributor takes >2 hours to figure out where things live
- A release shipped without a CHANGELOG entry
- A doc references a system that no longer exists
## When NOT to Use
- Greenfield project, day one — README will exist; full policy can wait until week 2
- Throwaway prototype
- A single typo fix in one doc
## Common Rationalizations
| Thought | Reality |
|---------|---------|
| "The code is self-documenting" | Code shows *what*, not *why*. Two months later the original author cannot reconstruct why. |
| "Docs get stale anyway, why bother" | Dated docs with code links rot slower than undated docs. The half-life of a comment near its code is years; far from its code, weeks. |
| "README is enough" | README without subdirectory docs creates a treasure hunt for every new contributor. |
| "We'll document before launch" | You won't. And if you do, the doc will be wrong because you'll write it from memory. |
| "Comments are noise" | Comments that explain WHY are signal. Comments that restate the code are noise. The fix is to write the right comments, not to delete all comments. |
| "Generated docs are good enough" | Generated docs answer "what does this function take" — not "when should I call it" or "what changes if I don't." |
## Red Flags
- A README that hasn't been touched since the repo was created
- A subdirectory with 10+ files and no entry-point doc
- A comment that restates the code: `// increment i by 1` next to `i++`
- A doc with no last-updated date or commit reference
- A dead link in any doc (broken internal link or 404 external)
- A CHANGELOG missing entries for the last 2 releases
- A doc describing a system that was deleted or renamed 3 months ago
- "TODO: document this" markers older than 90 days
## Core Process
### Step 1: Define the README standard
In `.forge/docs-policy.md`, the README contract for every repo top-level:
```markdown
# <project name>
One-sentence description.
## What this is
2-3 sentence description.
## Status
Stable / Beta / Experimental — and what that means for breaking changes.
## Quick start
The single command (or 3) that gets a developer running.
## Where things live
Pointers to subdirectory READMEs.
## Contributing
How to propose a change. Link to CONTRIBUTING.md if it exists.
## License
SPDX identifier.
```
For every subdirectory with >5 files: a README that answers "what is in here, why is it here, who owns it."
### Step 2: Set the in-code comment policy
The rule: **explain WHY, not WHAT.**
| Bad (WHAT) | Good (WHY) |
|---|---|
| `// increment i` | `// skip the sentinel row at index 0` |
| `// loop over users` | `// fan-out concurrency capped at 5 to respect upstream rate limit` |
| `// returns null` | `// returns null when the user has been soft-deleted; callers must filter` |
| `// magic number 86400` | `// 86400 = 24h in seconds; matches the auth token TTL in config.ts` |
Comments are required for:
- Non-obvious algorithmic choices (why this sort order, why this caching)
- Workarounds (`// workaround for issue-1234 in upstream-lib v3.x`)
- Cross-file invariants (`// invariant: ordersByUser is updated by users.ts:create()`)
- Hot-path performance decisions
Comments are forbidden for:
- Restating the obvious
- Commented-out code (delete it; git remembers)
- Personal opinions
### Step 3: Establish doc-rot prevention
Every doc carries:
- **Last-updated date** at the top (or a `<!-- updated: YYYY-MM-DD -->` footer)
- **Code links** that resolve at HEAD (use permalinks to `main`, not commit hashes) — if the link 404s, CI fails
- **A scope statement** — what this doc covers, what it doesn't
- **An owner** — a person or team responsible for keeping it current
Prefer generated docs (typedoc, rustdoc, godoc) for API reference. Hand-written docs for *concepts*, *workflows*, and *decisions* (ADRs).
### Step 4: Define the public-vs-internal doc split
In `.forge/docs-policy.md`:
- **Public docs** — user-facing, marketing-grade, versioned (cross-ref `api-design` for endpoint docs)
- **Internal docs** — engineering-facing, in-repo, allowed to assume context (`CONTRIBUTING.md`, ADRs, runbooks)
- **Confidential docs** — credentials, customer data, financials — never in the repo
Each doc has a banner indicating its tier.
### Step 5: Set changelog discipline
Follow [Keep a Changelog](https://keepachangelog.com): one entry per user-visible change, grouped by `Added`, `Changed`, `Deprecated`, `Removed`, `Fixed`, `Security`. Breaking changes flagged with `BREAKING:` prefix. Refactors don't get entries unless they affect performance, security, or behavior. Updated *in the PR that makes the change*, not at release time.
### Step 6: Audit for dead links and stale docs
CI job runs weekly:
- Check every internal link resolves
- Check every external link returns 2xx
- Flag any doc with last-updated > 180 days where the linked code has changed since
- Flag any TODO older than 90 days
Failures open tickets, not block CI (these are guideposts, not gates).
## Verification
- [ ] `.forge/docs-policy.md` written
- [ ] Every repo top-level has a README following the standard
- [ ] Every subdirectory with 5+ files has a README
- [ ] No comment in the codebase restates obvious code (spot-check via review)
- [ ] No commented-out code in the codebase (grep `^// .*[a-zA-Z(]` for obvious patterns)
- [ ] Every doc has a last-updated date and an owner
- [ ] CHANGELOG entries exist for the last 5 releases, grouped by Keep-a-Changelog categories
- [ ] No dead links in any in-repo doc (CI verified)
- [ ] No TODO comments older than 90 days without a tracking issue
---
> Source: [aneja5/forge-skills](https://github.com/aneja5/forge-skills) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-22 -->
按说明文件中的顺序排列。
概述
何时使用
何时不使用
常见的合理化理由
危险信号
文件/命令 -> .forge/docs-policy.md · code-review-and-quality · shipping-and-launch · // increment i by 1 · i++ · // increment i · // skip the sentinel row at index 0 · // loop over users
内容校验值 -> 29c99a429921
当前原文的自动摘译,尚未人工审校。
概述
定义项目的文档契约——记录什么、存放在哪里、如何保持最新状态——在文档腐烂之前。输出为
.forge/docs-policy.md:每个存储库和子目录的自述文件标准、代码内注释政策(为什么而不是什么)、文档腐烂预防规则(日期、代码链接、生成的文档)、公共与内部文档分割和变更日志规则。与code-review-and-quality(审查强制执行策略)和shipping-and-launch(每个版本更新的变更日志)配对。何时使用
存储库已超过 3 个月,自第一次提交以来,自述文件尚未被触及 子目录已增长到 5 个以上文件,没有入口点文档 代码内注释主要是重述代码,而不是解释意图 新贡献者需要超过 2 小时才能弄清楚事物的位置 发布的版本没有变更日志条目
何时不使用
新建项目,第一天——自述文件将存在;完整的政策可以等到第 2 周 一次性原型 一份文档中的一个拼写错误修复
常见的合理化理由
想法·现实“代码是自记录的”·代码显示什么,而不是为什么。两个月后,原作者无法重构原因。 “无论如何,文档都会过时,何必麻烦” · 带有代码链接的过时文档比未注明日期的文档腐烂得慢。靠近其代码的注释的半衰期是数年;距离它的代码还很远,几周。 “README 就足够了” · 没有子目录 docs 的 README 为每个新贡献者创造了一次寻宝之旅。
危险信号
自创建存储库以来尚未触及的自述文件 包含 10 多个文件且没有入口点文档的子目录 重述代码的注释:
i++旁边的// increment i by 1没有上次更新日期或提交引用的文档 任何文档中的死链接(损坏的内部链接或 404 外部链接)