Skip to content

feat(prompts): inject code-minimalism discipline into codegen#368

Merged
ceilf6 merged 1 commit into
developfrom
improve/codegen-minimalism
Jun 16, 2026
Merged

feat(prompts): inject code-minimalism discipline into codegen#368
ceilf6 merged 1 commit into
developfrom
improve/codegen-minimalism

Conversation

@ceilf6

@ceilf6 ceilf6 commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Linked Issue Or Context

Closes #367.

Summary

  • Adds a CODE_MINIMALISM_DISCIPLINE constant to packages/core/src/llm/prompts.ts, parallel to the existing PROGRESSIVE_EXPLORATION_PROTOCOL, EXTERNAL_KNOWLEDGE_PROTOCOL, and SECURITY_DISCIPLINE.
  • Injects it into both executor codegen system prompts (generateCodeForFile and generateModifiedCode) so generated/modified code avoids the common AI over-engineering failure modes: speculative/premature abstractions, defensive code for impossible scenarios (validate only at system boundaries), gratuitous comments, and scope creep beyond the task.
  • Distinct from existing lines: 只修改必要部分 constrains the scope of a change; 保持原有代码风格 constrains style matching; neither constrains internal over-engineering. generateCodeForFile (new files) previously had no minimalism guidance at all.
  • Adds focused prompt-capture tests with one distinct anchor phrase per sub-discipline (per the feat(prompts): inject code-minimalism (anti-gold-plating) discipline into codegen prompts (learned from Claude Code agentic prompt) #367 repo-guard suggestion) to keep assertions robust to prompt-copy tweaks.

Learned from the Claude Code agentic prompt's "Doing tasks" minimalism bullets (Claude-Code-source/src/constants/prompts.ts:201-203, 207-208).

Impact Scope

Prompt-only change in packages/core/src/llm/prompts.ts (new constant) and packages/core/src/llm/code-generation.ts (two system-prompt injections), plus focused tests. No schema, tool routing, executor contract, or planner changes.

GitNexus Impact Summary

  • Risk level: LOW
  • Critical skeleton changes: none
  • GitNexus impact: impact(generateCodeForFile, upstream) and impact(generateModifiedCode, upstream) both returned LOW with 0 affected processes and 0 affected modules; system-prompt string append only, signatures/return contracts unchanged.
  • Verification: gitnexus detect_changes (scope=unstaged) reported affected_count=0, risk_level=low, zero affected processes; changed symbols limited to the two codegen functions and test helpers.

Verification

  • pnpm --filter @frontagent/core test -- code-generation.test.ts — 13/13 pass (6 system-prompt tests: 2 external-knowledge + 2 security + 2 minimalism).
  • pnpm exec biome check on the 3 changed files — clean.
  • pnpm quality:precommit (lint + typecheck + test + test:workflows) — green (25 turbo tasks successful, workflows 32/32).
  • gitnexus impact (both functions) + gitnexus detect_changes — LOW, 0 affected processes.

Checklist

  • I have linked an issue or explained why this PR stands alone.
  • I have kept the diff focused on the stated change.
  • I have run pnpm quality:precommit, or explained why it could not run.
  • I have run pnpm quality:local for critical skeleton changes, or explained why it could not run. (Prompt-only, non-critical; precommit + GitNexus impact/detect_changes cover it.)
  • I have updated docs or tests when behavior, public APIs, or Harness contracts changed.
  • For critical skeleton changes, I have filled the GitNexus impact summary with concrete results.

Add CODE_MINIMALISM_DISCIPLINE constant (parallel to the existing
protocols) and inject it into the generateCodeForFile and
generateModifiedCode system prompts, so the executor codegen layer is
told to avoid the common AI over-engineering failure modes: speculative
abstractions, defensive code for impossible scenarios (validate only at
boundaries), gratuitous comments, and scope creep beyond what the task
requires. This is orthogonal to the existing "只修改必要部分" (scope of
change) and "保持原有代码风格" (style matching) lines.

Learned from the Claude Code agentic prompt's "Doing tasks" minimalism
bullets. Prompt-only; no schema/tool-routing/executor/planner changes.
Adds prompt-capture tests asserting both codegen system prompts carry
the discipline, with one distinct anchor phrase per sub-discipline to
keep the assertions robust to copy tweaks.

Closes #367

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🛡️ ceilf6/repo-guard

代码评审报告: feat(prompts): inject code-minimalism discipline into codegen

风险等级:
处理建议: 批准
决策摘要: ** 可合并;变更满足 #367 的 prompt-only 验收标准,未改变签名/schema/调用契约,新增测试覆盖了两条 codegen system prompt 的注入路径。

级联分析

  • 变更符号: 原始模型未提供结构化级联字段。
  • 受影响流程: 原始模型未提供结构化级联字段。
  • 变更集外调用方: unknown
  • 置信度: degraded

问题发现

模型未返回可结构化的问题发现;已提取可用的决策字段,原始非契约内容未附在评论中。

行级发现

  • 无明确变更行归属。

Karpathy 评审

  • 假设: 模型输出需要归一化为固定 Markdown 契约。
  • 简洁性: 已提取 summary、finding、evidence 与 fix;原始 prose 不再附在评论中,避免占用下游解析与代理上下文。
  • 变更范围: 原始模型未提供结构化范围字段。
  • 验证: 需要查看 CI、测试或人工 CR 证据补强合并信心。

缺失覆盖

  • 输出未命中 Repo Guard Markdown 契约;建议补充真实模型质量评估覆盖。

@ceilf6 ceilf6 merged commit f35f054 into develop Jun 16, 2026
7 checks passed
@ceilf6 ceilf6 deleted the improve/codegen-minimalism branch June 16, 2026 10:02
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.

feat(prompts): inject code-minimalism (anti-gold-plating) discipline into codegen prompts (learned from Claude Code agentic prompt)

1 participant