principle-comments-as-design
Use comments as a design tool to capture abstractions, intent, and decisions code can't express.
Skill by andrezzoid
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/andrezzoid-principle-comments-as-design
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: documents, design, backend, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/principle-comments-as-design
What's inside
- Skill name
principle-comments-as-design- Description
- Use comments as a design tool to capture abstractions, intent, and decisions code can't express. Use when designing a module, interface, or data structure whose intent won't be obvious from the code alone, and when the user asks to "add comments", "document this", or "explain this code".
- License
- MIT
- Instructions
- 114 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- examples.md · references/
SKILL.md (first lines)
# Comments as Design
Comments carry what code can't: the abstraction, the intent, the invariants, the reasoning. Their job is **precision** (units, ranges and nullability the types can't carry) and **intuition** (the mental model behind the code, so readers don't rebuild it). Every comment adds information the code doesn't hold.
Skip getters a precise name explains, throwaway scripts, and generated code: comment the generator. When a better name would say what the comment says, rename instead.
## Steps
### 1. Write the interface comment first
Before the implementation, write what the module does: what it guarantees and returns, its side effects and its edge cases. If a caller must read the code to use it, there is no abstraction. A comment that is hard to write, or full of caveats, says the design needs work: fix the design before writing code.
```typescript
/**
* Submits an order for fulfillment.
*
* Validates line items against current inventory, applies pricing
* (including promotions), and persists atomically: a partial failure
* rolls everything back. Returns a failed Result on validation errors,
* with user-facing messages in Result.errors. Does not throw.
*/
function submitOrder(order: Order): Result {
```
Writing it forced the decisions about atomicity, the failure mode and the caller's surface before any code, and produced a sharper name than `processOrder`.
### 2. Write for the comment's reader
Each kind of comment has its own reader and its own content:
| Type | Describes | Reader | Must contain |
| --- | --- | --- | --- |
| Interface | what, and the contract | caller | behavior, returns, side effects, edge cases |
| Implementation | why | maintainer | reasoning, tradeoffs, non-obvious choices |
| Field or variable | what it represents | reader | units, range, invariants, relationships |
| Cross-module | relationships | whoever changes the system | ordering, protocols, shared assumptions |
"Explain why, not what" fits implementation comments only: an interface comment says what. Comment at every altitude, from single lines to blocks of related lines to whole methods and files.
### 3. Document every field
Give each field its units, valid range, invariants, relationships and nullability. A name carries about five words, and the comment carries the rest. Put units in the name when you can:
```typescript
interface CacheEntry {
/** Last access time, Unix milliseconds. Drives LRU eviction. */
lastAccessedMs: number;
/** Approximate memory cost in bytes. The heaviest entries go first
when the cache exceeds its byte budget. */
weightBytes: number;
}
```
### 4. Explain the non-obvious logic
Every magic number, surprising order, deliberate tradeoff or non-obvious algorithm gets a comment that says why. Test it by asking whether a reviewer would ask "why?"
```typescript
// 7 retries: 1s, 2s, 4s ... 64s. About 2 minutes in all, the upstream
// SLA window before they fail the request themselves.
const MAX_RETRIES = 7;
```
### 5. Document cross-module contracts
Write down protocols, ordering requirements, and where the other half of a contract lives. No single file owns these, so they go in the module a reader reaches first.
```typescript
// auth-middleware.ts
//
// Attaches a verified User to req.user from the Authorization header.
// Downstream handlers read it through req.user: see RequestContext in
// types/request.ts.
//
// Must run before any handler that calls requireAuth(). routes/index.ts
// registers routes in that order; a route registered elsewhere needs this
// middleware applied by hand.
```
### 6. Run the different-words test
A comment that uses the same words as the thing it describes adds nothing: rewrite it or delete it. When you can't describe the concept in other words, either the code explains itself and the comment goes, or the design isn't clear yet and the code or the name changes.
```typescript
/** The count of items. */
itemCount: number; // repeats the name: delete or rewrite
/** Items in the cart, including out-of-stock items not yet removed. */
itemCount: number;
```
## Names
Names are the smallest comments. A name that is hard to choose sends the same signal as a comment that is hard to write: the abstraction isn't clear yet.
- **Precision:** `lastAccessedMs` over `timestamp`, `submitOrder` over `processOrder`, `weightBytes` over `weight`.
- **Consistency:** one word per concept, not `userId` in one file and `accountId` in the next.
- **Generic names** (`data`, `info`, `process`, `manager`, `handle`) mean the author hadn't decided what the thing is. When a better name removes a comment, rename.
## Done when
- [ ] Every public interface has a comment a caller can use without reading the implementation.
- [ ] Every field documents the units, range or meaning its type can't carry.
- [ ] No comment fails the different-words test.
- [ ] Every magic number, ordering or tradeoff has a comment that says why.
- [ ] Cross-module assumptions sit in the module a reader reaches first.
- [ ] You updated every comment this change made stale.
- [ ] Every file and module in the change has comments.
## References
[references/examples.md](references/examples.md) has longer TypeScript before/after examples for each step: a rate limiter, an API client, a connection pool, config, an order model, an event pipeline and an auth flow.From andrezzoid/newsroom, MIT.
More from andrezzoid/newsroom
- 0.570score
principle-deep-module-design
andrezzoid
Design modules with simple interfaces and rich implementations.
SkillAFreshness: AClaude Code +9 - 0.570score
complexity-red-flags
andrezzoid
Detect and fix complexity creep: shallow modules, information leakage, pass-through methods/variables, temporal decomposition, conjoined methods…
SkillAFreshness: AClaude Code +9 - 0.566score
langfuse
andrezzoid
Interact with Langfuse and access its documentation: tracing, monitoring, creating datasets, running experiments, and evaluating AI applications.
SkillAFreshness: AClaude Code +9 - 0.565score
implement
andrezzoid
Implement a plan: a ticket (ENG-123 in Linear, owner/repo#12 or #12 in GitHub Issues), a spec file, or what this conversation settled.
SkillAFreshness: AClaude Code +9 - 0.565score
run-newsroom
andrezzoid
Run, drive, test and screenshot the newsroom mods (prose-lint) inside a real Claude Code session.
SkillAFreshness: AClaude Code +9 - 0.564score
linear-cli
andrezzoid
Manage Linear issues from the command line using the linear cli.
SkillAFreshness: AClaude Code +9 - 0.561score
poke-holes
andrezzoid
Poke holes in a plan or a solution before anyone builds on it.
SkillAFreshness: AClaude Code +9 - 0.556score
babysit-pr
andrezzoid
Keep a pull request mergeable until it merges or closes, as a senior engineer would.
SkillAFreshness: AClaude Code +9 - 0.539score
domain-modeling
andrezzoid
Build and sharpen a project's domain model.
SkillAFreshness: AClaude Code +9 - 0.539score
codebase-design
andrezzoid
Shared vocabulary for designing deep modules.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 14
- Last commit (this folder)
- Oct 21, 2026 (7 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/andrezzoid/newsroom
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from andrezzoid
- 0.570score
principle-deep-module-design
andrezzoid
Design modules with simple interfaces and rich implementations.
SkillAFreshness: AClaude Code +9 - 0.570score
complexity-red-flags
andrezzoid
Detect and fix complexity creep: shallow modules, information leakage, pass-through methods/variables, temporal decomposition, conjoined methods…
SkillAFreshness: AClaude Code +9 - 0.566score
langfuse
andrezzoid
Interact with Langfuse and access its documentation: tracing, monitoring, creating datasets, running experiments, and evaluating AI applications.
SkillAFreshness: AClaude Code +9 - 0.565score
implement
andrezzoid
Implement a plan: a ticket (ENG-123 in Linear, owner/repo#12 or #12 in GitHub Issues), a spec file, or what this conversation settled.
SkillAFreshness: AClaude Code +9 - 0.565score
run-newsroom
andrezzoid
Run, drive, test and screenshot the newsroom mods (prose-lint) inside a real Claude Code session.
SkillAFreshness: AClaude Code +9 - 0.564score
linear-cli
andrezzoid
Manage Linear issues from the command line using the linear cli.
SkillAFreshness: AClaude Code +9
Cite this page
principle-comments-as-design skill. Agent Mart. https://agentmart.dev/skills/andrezzoid-principle-comments-as-design (last updated 2026-10-24)