Skip to content

feat(wbfy): generate a comment policy that forbids restating the code - #1329

Merged
exKAZUu merged 2 commits into
mainfrom
feat/comment-policy
Sep 15, 2026
Merged

exKAZUu merged 2 commits into
mainfrom
feat/comment-policy

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Sep 15, 2026

Copy link
Copy Markdown
Member

Why

The generated Coding Style told agents to write comments "only for hard-to-understand code" with "what" in JSDoc, which still lets JSDoc restate signatures and types. Every reader of a private WillBooster repository has the source, so such text is a second copy that must be kept in sync with the code for nothing. The new rule states when a comment is worth writing in terms of what breaks without it, mirroring the existing test rule, so the policy does not merely shift bloat from "what" to "contracts".

Requirements

  • required: As a rule, do not write in JSDoc or documentation information that is easily read from the code.
  • required: In private repositories, JSDoc carries only information that cannot be read from the code.
  • required: Make the rule explicit about when a comment should be written, so that "contracts not visible in types" does not grow JSDoc beyond today.
  • required: Apply the change consistently across wbfy's agents.ts and the related skills.
  • chosen: A comment is written only when a plausible edit would break something without that knowledge and no type check, lint rule, or existing test would catch it, after first trying to encode the knowledge in code (a name, a type, an assert, a test).
  • chosen: The exception for the exported API of packages published to npm is emitted only for public repositories, since private repositories never publish to the public registry.
  • chosen: Keep the added instruction text minimal: wording changes that lengthen a prompt or skill are accepted only when the improvement clearly outweighs the added tokens; other wording suggestions are rejected.

Customer Summary

AGENTS.md and its sibling files generated by wbfy now tell agents never to restate the code in comments or JSDoc, when a comment is worth writing, where to put it (JSDoc for a symbol's contract, inline for specific lines), and to delete comments that fail the test in files they touch. Public repositories additionally allow JSDoc on the exported API of npm-published packages.

Technical Summary

generateAgentCodingStyle in packages/wbfy/src/generators/agents.ts builds the rule from rootConfig.isPublicRepo, replacing the previous single line. This repository's own generated instruction files (AGENTS.md, CLAUDE.md, GEMINI.md, .cursor/rules/general.mdc, .gemini/styleguide.md) are regenerated in the same PR so they carry the new rule. The matching review and simplification criteria are in WillBooster/agentic-workflows#685 and WillBooster/review-booster#338.

Testing

bun run verify passed. The generated instruction files were produced by running the local wbfy build on this repository; the unrelated dependency bumps that run also proposed were left out.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the coding style guidelines generated by wbfy to reduce documentation bloat. By mandating that comments only explain 'why' rather than 'what', the changes ensure that JSDoc and inline comments provide actual value rather than redundant information. This policy is applied conditionally based on repository visibility, ensuring that public npm packages retain necessary documentation for external consumers while private codebases remain clean and focused on code-level self-documentation.

Highlights

  • Comment Policy Update: Implemented a new coding style rule that forbids restating code, names, or types in comments and JSDoc, shifting the focus toward documenting non-obvious contracts and external dependencies.
  • Conditional JSDoc Exception: Added an exception for public repositories where exported APIs of npm-published packages may include JSDoc to assist users who do not have access to the source code.
  • Agent Instruction Refinement: Updated the agent coding style generator to explicitly instruct AI agents to delete existing comments that fail the new 'restatement' test when they touch files.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


The code is clear, the names are bright, No need to state what's in plain sight. If types and names tell all the tale, Then redundant comments must surely fail.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the agent coding style instructions in packages/wbfy/src/generators/agents.ts to include more specific guidance on JSDoc and comments, particularly regarding public npm registry packages. The review comment suggests improving the readability of the long prompt strings by splitting them across multiple lines in the source code, which is a valid improvement for maintainability.

Comment on lines +178 to +183
// Only public repositories publish packages to the public npm registry, whose users read the
// JSDoc without the source; private repositories are read only by agents that have the source.
const npmApiException = rootConfig.isPublicRepo
? ' Exception: the exported API of a package published to npm may carry JSDoc describing what it does and how to call it, because its users read it without the source.'
: '';
const commentInstruction = `- Comments and JSDoc: every reader has the source, so never restate what the code, its names, or its types already say (e.g., \`@param name The name\`, \`@returns the result\`, a narration of the control flow). Write one only when a plausible edit (simplifying, deleting, reordering, replacing) would break something without that knowledge and no type check, lint rule, or existing test would catch the breakage; first try to encode the knowledge in code (a name such as \`timeoutMs\`, a type, an \`assert\`, a test) and comment only what cannot be encoded: a deliberately odd-looking workaround, a dependency on a fact outside the repository (an external API's behavior, an agreement with another system), or a rejected alternative and why. Put it in JSDoc when it is a contract of the declared symbol, so callers see it, and in an inline comment when it concerns specific lines. Delete comments that fail this test in files you touch.${npmApiException}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The prompt instruction string commentInstruction and its exception npmApiException are extremely long (over 800 characters on a single line), which makes the TypeScript source code difficult to read and maintain.

We can improve readability by splitting these long strings across multiple lines in the source code using backslashes (\) to escape the newlines. This keeps the compiled output as a single continuous line (without introducing actual newlines in the generated markdown) while keeping the source code clean and readable.

  // Only public repositories publish packages to the public npm registry, whose users read the
  // JSDoc without the source; private repositories are read only by agents that have the source.
  const npmApiException = rootConfig.isPublicRepo
    ? ' Exception: the exported API of a package published to npm may carry JSDoc describing \
what it does and how to call it, because its users read it without the source.'
    : '';
  const commentInstruction = `- Comments and JSDoc: every reader has the source, so never restate what the code, \
its names, or its types already say (e.g., \\`@param name The name\\`, \\`@returns the result\\`, a narration of the control flow). \
Write one only when a plausible edit (simplifying, deleting, reordering, replacing) would break something without that knowledge \
and no type check, lint rule, or existing test would catch the breakage; first try to encode the knowledge in code \
(a name such as \\`timeoutMs\\`, a type, an \\`assert\\`, a test) and comment only what cannot be encoded: a deliberately \
odd-looking workaround, a dependency on a fact outside the repository (an external API's behavior, an agreement with \
another system), or a rejected alternative and why. Put it in JSDoc when it is a contract of the declared symbol, \
so callers see it, and in an inline comment when it concerns specific lines. Delete comments that fail this test in \
files you touch.${npmApiException}`;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the single-line literal. Long instruction strings in this file are already written on one line (e.g. the self-hosted runner instruction above), oxfmt does not wrap template literals, and backslash line continuations inside a template literal are easy to break when editing (a trailing space after the backslash changes the emitted text). The rendered rule is reviewed in the generated AGENTS.md, not in this source line.

Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Sep 15, 2026
@exKAZUu
exKAZUu merged commit c8c9001 into main Sep 15, 2026
6 checks passed
@exKAZUu
exKAZUu deleted the feat/comment-policy branch September 15, 2026 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant