claude-code - 💡(How to fix) Fix [BUG] System prompt rule 'Never write multi-paragraph docstrings... one short line max' breaks language-idiomatic API documentation [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54587Fetched 2026-04-30 06:41:32
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Error Message

Error Messages/Logs

N/A. This is a prompt-quality issue, not a runtime error. The symptom is silently substandard doc comments in generated Go, Python, Java, Rust, or TypeScript code.

Root Cause

The Go case is especially sharp because the language's tooling actively enforces paragraph structure. gofmt normalizes godoc paragraphs (single blank // lines between them). The official Go Doc Comments specification at https://go.dev/doc/comment uses io.Copy's two-paragraph godoc as a canonical example. Language server gopls flags missing or non-conforming doc comments on exported declarations. A Go file with one-line-max godocs on every exported function is non-idiomatic by tooling standards, not just style preference.

Fix Action

Fix / Workaround

Workaround in use: a machine-level ~/.claude/CLAUDE.md override that scopes the one-line-max rule to non-godoc and non-docstring comments, and points to each language's idiomatic doc spec. This works locally, but every Claude Code user generating code in these languages would need the same override. Defaulting to substandard docs is a poor floor.

Code Example

In code: default to writing no comments. Never write multi-paragraph docstrings or multi-line comment blocks - one short line max. Don't create planning, decision, or analysis
 ▎ documents unless the user asks for them - work from conversation context, not intermediate files.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

The Claude Code built-in system prompt contains the rule "Never write multi-paragraph docstrings or multi-line comment blocks - one short line max" (in the "Text output" section, under "In code"). Applied as written, this rule directly contradicts the documentation conventions of most major languages with structured doc systems: Go, Python (PEP 257), Java (Javadoc), C# (XML doc comments), Rust (rustdoc), and TypeScript (TSDoc). When Claude generates exported-API code in these languages and follows the rule, the resulting doc comments fail normal language idioms and code-review standards.

The Go case is especially sharp because the language's tooling actively enforces paragraph structure. gofmt normalizes godoc paragraphs (single blank // lines between them). The official Go Doc Comments specification at https://go.dev/doc/comment uses io.Copy's two-paragraph godoc as a canonical example. Language server gopls flags missing or non-conforming doc comments on exported declarations. A Go file with one-line-max godocs on every exported function is non-idiomatic by tooling standards, not just style preference.

The rule's intent is sound (preventing AI-generated narration that restates what code does), but the absolute "one short line max" formulation overshoots that intent and breaks language-idiomatic API documentation.

What Should Happen?

The rule should target what it actually means to prevent: AI narration that paraphrases what the code already says, and sprawling comment blocks on trivial declarations. It should not block language-idiomatic doc comments on exported APIs.

A possible reformulation: "Default to no comments. When a doc comment is warranted (for example, an exported declaration in a typed language with a documentation system), follow the language's idiomatic doc convention. Do not add commentary that restates what the code already says, and do not write multi-paragraph blocks for trivial declarations." This preserves the original anti-verbosity intent without breaking language standards.

Error Messages/Logs

N/A. This is a prompt-quality issue, not a runtime error. The symptom is silently substandard doc comments in generated Go, Python, Java, Rust, or TypeScript code.

Steps to Reproduce

  1. Open a Go project (or Python, Java, Rust, TypeScript) in Claude Code with no project-level overrides.
  2. Ask Claude to add a non-trivial exported function to a public package.
  3. Observe that Claude produces either no doc comment or a one-line doc comment, even when the function is complex enough that idiomatic API docs would be multi-paragraph.
  4. For Go specifically, compare against any function in the standard library (io.Copy, net/http.Handler, encoding/json.Marshal). The stdlib uses identifier-prefixed multi-paragraph godocs as the norm.

To confirm the rule is the cause, add an override in CLAUDE.md: "Godoc comments follow https://go.dev/doc/comment, including multi-paragraph structure when warranted." Re-prompt for the same function. Claude now produces idiomatic multi-paragraph godocs, confirming that the built-in rule was the constraint.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.119 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

The rule appears in the "Text output (does not apply to tool calls)" section of the system prompt, in the "In code:" sub-bullet. Full text:

 ▎ In code: default to writing no comments. Never write multi-paragraph docstrings or multi-line comment blocks - one short line max. Don't create planning, decision, or analysis
 ▎ documents unless the user asks for them - work from conversation context, not intermediate files.

The "default to no comments" portion is sound and aligns with the "Doing tasks" section's "only add a comment when the WHY is non-obvious" rule. The "one short line max" hard cap is the part that breaks down for typed-language API documentation.

References:

Workaround in use: a machine-level ~/.claude/CLAUDE.md override that scopes the one-line-max rule to non-godoc and non-docstring comments, and points to each language's idiomatic doc spec. This works locally, but every Claude Code user generating code in these languages would need the same override. Defaulting to substandard docs is a poor floor.

extent analysis

TL;DR

The issue can be resolved by reformulating the Claude Code system prompt rule to allow for language-idiomatic doc comments on exported APIs.

Guidance

  • Review the current system prompt rule and identify the specific part that is causing the issue: "Never write multi-paragraph docstrings or multi-line comment blocks - one short line max".
  • Consider reformulating the rule to target AI narration that paraphrases what the code already says, while allowing for language-idiomatic doc comments on exported APIs.
  • Test the reformulated rule by generating code in different languages (e.g. Go, Python, Java, Rust, TypeScript) and verifying that the resulting doc comments follow the language's conventions.
  • If a workaround is needed, consider using a machine-level override in ~/.claude/CLAUDE.md to scope the one-line-max rule to non-godoc and non-docstring comments.

Example

A possible reformulation of the rule could be: "Default to no comments. When a doc comment is warranted (for example, an exported declaration in a typed language with a documentation system), follow the language's idiomatic doc convention. Do not add commentary that restates what the code already says, and do not write multi-paragraph blocks for trivial declarations."

Notes

The reformulated rule should preserve the original anti-verbosity intent while allowing for language-idiomatic doc comments on exported APIs. However, the exact wording and implementation may require further refinement and testing.

Recommendation

Apply a workaround by using a machine-level override in ~/.claude/CLAUDE.md to scope the one-line-max rule to non-godoc and non-docstring comments, until a revised system prompt rule can be implemented. This will allow for language-idiomatic doc comments on exported APIs while minimizing the impact of the current rule.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] System prompt rule 'Never write multi-paragraph docstrings... one short line max' breaks language-idiomatic API documentation [1 participants]