Write Comments
Apply codebase commenting conventions for TypeScript, Python, and any language.
by organizzolini Β· MIT
The skill
Apply codebase commenting conventions for TypeScript, Python, and any language. USE WHEN writing or reviewing comments, adding section comments, organizing code into logical groups, or asked about comment style. Covers when to comment, how to write good comments, section comment format (emoji + capitalized name), emoji reference table, and anti-patterns to avoid (obvious comments, redundant JSDoc, TODO lint bypasses, dash-line dividers).
Commenting
When to Comment
Code should be self-explanatory through good naming. Comments add value only when they explain why something is done β not what it does.
Comment when:
- Explaining non-obvious intent or business logic
- Documenting known edge cases or external constraints
- Noting a workaround with a link to the upstream issue
Don't comment when:
- The code is clear from reading it
- You're narrating what the code obviously does
How to Comment
Good Comments
// Delay is intentional: the third-party API enforces a 1s rate limit per key
await delay(1000);
// Uses linear search because this list is always < 10 items and never hot
const found = items.find((item) => item.id === targetId);
Bad Comments
// Increment counter
counter++;
// Call the API
const result = await fetchData();
// Return the value
return value;
Anti-Patterns
Obvious Comments
// Bad: restates what the code already says
const user = getUser(id); // Get the user by id
Redundant JSDoc
Avoid JSDoc on private functions or functions whose signature is self-documenting.
// Bad: JSDoc that adds nothing
/**
* Gets the user.
* @param id - The user id.
* @returns The user.
*/
function getUser(id: string): User { ... }
// Good: JSDoc only when it adds non-obvious context
/**
* Returns the user record, or throws `UserNotFoundError` if the id is
* not present in the active-users projection. Does NOT check the archive.
*/
function getUser(id: string): User { ... }
TODO Comments
Don't leave TODO comments to bypass lint rules or defer real fixes.
// Bad: silences a rule without explanation
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function process(data: any) { ... }
// Good: fix the underlying issue instead
function process(data: unknown) { ... }
If a TODO is genuinely needed (tracked work), include a ticket reference:
// TODO(#1234): remove once the upstream API supports batch deletes
Divider Comments
// Bad: dash dividers
// ---------------------------------------------------------------------------
// Configuration
// ---------------------------------------------------------------------------
// Bad: equals dividers
// ===========================
// Configuration
// ===========================
// Bad: plain section label with no emoji
// Configuration
// Bad: #region blocks
//#region π§ Configuration
//#endregion
Use emoji section comments instead β see Section Comments below.
Section Comments
When a file benefits from logical groupings, mark each section with a single-line emoji comment.
Format
// <emoji> <Section name>
- Emoji first β conveys purpose at a glance
- Capital first letter β
// π§ Configuration, not// π§ configuration - Single line β no closing marker, no surrounding dash lines
- Python uses
#instead of//β same rules otherwise
Examples
TypeScript / JavaScript
// π§ Configuration
const MAX_RETRIES = 3;
const API_TIMEOUT = 5_000;
// π Mocks
vi.mock("./api.js");
// π§ͺ Tests
describe("MyService", () => { ... });
NestJS service layout
@Injectable()
export class MyService {
// π Dependency injection
constructor(private readonly logger: LoggerService) {}
// π Private fields
// π Public fields
// π Private methods
// π Public methods
}
Python
# π§ Configuration
MAX_RETRIES = 3
# π§ͺ Tests
class TestMyService(unittest.TestCase): ...
Emoji Reference
| Emoji | Typical use |
|---|---|
| π | Dependency injection, constructors |
| π§ | Configuration, constants |
| ποΈ | Types, data structures |
| π·οΈ | Type aliases, interfaces |
| βοΈ | Constants module |
| π | Private fields |
| π | Public fields |
| π | Private methods |
| π | Public methods |
| π | Mocks |
| π§ͺ | Tests |
| π | Relations, associations, links |
| π | Queries |
| ποΈ | Mutations |
| π | Headings, lists |
| π¦ | Code blocks, packages |
| π | Paragraphs, docs |
| πΌοΈ | Images |
| βοΈ | Inline formatting |
| β | Completed / passing |
| β | Thematic breaks |
| π¬ | Blockquotes |
| π | Tables |
| π | Grammar groups, large topic areas |
Rules Summary
- Format:
// <emoji> <Section name>(TypeScript/JS) or# <emoji> <Section name>(Python) - Section name: capitalized first letter, short noun phrase
- Never wrap a section comment in dash lines or any other delimiter
- Never use
#region/#endregionβ plain emoji comments are sufficient - Choose an emoji that conveys the section's purpose; consult the table above
Use this skill
Connect your agent to the Skill Store MCP server and ask for it by ref: organizzolini/write-comments-92982873347.
Details
- Publisher
- organizzolini
- Category
- Software Development βΊ Developer docs & tooling
- License
- MIT
- Updated
- 2026-10-19
References
More from organizzolini
- Agent Session Hooks Explains how startup scripts run at the start of agent sessions and inject context.
- Ask Matt Ask which skill or flow fits your situation.
- Backup Code Create a safety backup before potentially destructive actions.
- Brainstorming You MUST use this before any creative work - creating features, building components, adding functβ¦