Semantic code comments

From SteelMorgan/1c-agent-based-dev-framework · View interactive version

Semantic code comments is an AI agent skill from the GitHub repository SteelMorgan/1c-agent-based-dev-framework. Explain why in comments, do not restate the code

How to use this skill

Skill file

Semantic Comments in Code

A good comment explains why, not what. Names, structure, and expressions already show what the code does; a comment is needed for business meaning, constraints, tradeoffs, and hidden invariants.

Principle

Code is written once, but read many times. If a future reader asks “why is it like this?”, “what will break if we remove it?”, “what business rule is being protected here?” - a semantic comment is needed.

What to comment / what NOT to comment

| Comment (why) | DO NOT comment (what) |

|-------------------------|-------------------------|

| Non-obvious business rules | Code restatement (// adding A and B) |

| Protection against external failures and edge cases | Obvious operations (// incrementing the counter) |

| Workaround and tradeoffs | |

| Hidden invariants and call order | |

| Reasons for rejecting the obvious solution | |

| Magic numbers and constants | |

A comment that contradicts the code is unacceptable: an outdated comment is worse than none - it creates false confidence. When changing code, check nearby comments.

Good:

// Скидку применяем только после подтверждения лимита, потому что договор
// может запрещать ретроспективное изменение цены.
Если ЛимитПодтвержден И ДоговорРазрешаетИзменениеЦены Тогда

Bad:

// Плохо: складываем A и B.
Сумма = A + B;

SHOULD

How to Phrase It

| Good | Bad |

|--------|-------|

| "We do not use X because Y" | "X is here" |

| "Protection against an empty response from an external service" | "Checking the value" |

| "If removed, the period invariant will break" | "Do not touch" |

| "First we populate the cache because the next request reads from it" | "Populating the cache" |

Relationship with Change Marking

agent-code-marking shows who changed the code and when; semantic-code-comments explains why the code is structured this way. Markers provide auditability, comments provide meaning.

The marker is the only place where the task number appears in the code; the task number is not included in identifiers (names of procedures, functions, variables, modules, tests, and metadata).


depends_on:


Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.