Force Pure Code Output Methods | Generated by AI

Home 2025.08

Got it—you want Claude Code (and your “router” workflows that call it) to output code only, with no inline comments/docstrings/explanations. Here are three reliable ways to enforce that, from softest to strongest. No tables—just straight steps.


1) Put the rule in CLAUDE.md (global or per-project)

Claude Code loads “memory” files automatically and follows them across sessions. Add a short, explicit rule:

Global (all projects): ~/.claude/CLAUDE.md Per project (checked in): ./CLAUDE.md

# Output rules
- When generating code, output code only.
- Do not include inline comments, block comments, docstrings, or explanatory prose unless I explicitly ask.
- Keep messages concise; if an explanation is needed, put it after the code block and only if I ask.

Tip: you can manage these memories with /memory and quickly add new ones by starting a message with # in Claude Code. (Anthropic)


2) Make a custom Output Style that bans comments (stronger)

Output Styles modify Claude Code’s system prompt. Create one and switch to it:

Create:

/output-style:new I want an output style that always outputs code without any comments or docstrings, no explanations.

This creates a file under ~/.claude/output-styles/…. You can edit it to ensure the rule is unambiguous:

---
name: Code Only (No Comments)
description: Always emit code without comments/docstrings; no explanations unless asked.
---
# Instructions
- You are coding in "code-only" mode.
- Never include inline comments, block comments, or docstrings.
- Do not add prose before or after code unless explicitly requested.

## Specific Behaviors
- If a task implies tests, output the test file(s) as code only.
- If clarification is needed, ask briefly, no explanations.

Activate:

/output-style "Code Only (No Comments)"

(Output styles directly change the system prompt; you can switch with /output-style anytime.) (Anthropic)


3) Append an extra system prompt at runtime (strongest / per-session)

If you launch Claude Code from CLI or a script, add:

claude --append-system-prompt "Always output code only. No inline comments, no block comments, no docstrings, no explanations unless explicitly asked."

You can also set this via /config if you prefer persistent project settings. (Anthropic notes you can use --append-system-prompt to modify Claude Code’s behavior.) (Anthropic)


Where to put “router”-wide rules


Extra guardrails (optional but useful)

That’s it. If you tell me how you start Claude Code (desktop, VS Code, JetBrains, or terminal), I can give you a drop-in snippet for that setup.


Back Donate