Skip to content

Structure system prompt into composable sections - #5

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-811-structure-system-prompt-into-composable-sections-with-tests
May 29, 2026
Merged

TheGreatAxios merged 2 commits into
mainfrom
cl-811-structure-system-prompt-into-composable-sections-with-tests

Conversation

@TheGreatAxios

Copy link
Copy Markdown
Collaborator

Summary

  • Split prompt construction into composable pure section builders
  • Added prompt composition coverage for agent and chat prompts

Verification

  • bun run typecheck
  • bun run build
  • bun test (blocked: tests/unit/run-agent.test.ts exits after OPENAI_COMPATIBLE_API_KEY env var is required)

@linear-code

linear-code Bot commented May 29, 2026

Copy link
Copy Markdown
CL-811 Structure system prompt into composable sections with tests

Objective

Refactor the system prompt from a monolithic string into composable sections that can be tested independently.

Requirements

  • Break prompt into sections: tool-call discipline, submit rules, budget rules, plan rules
  • Each section is a pure function that returns a string
  • buildSystemPrompt() composes all sections into the final prompt
  • buildChatSystemPrompt() composes only the conversational sections
  • Test: prompt contains all required sections
  • Test: prompt contains all available tool names
  • Test: chat prompt does not contain submit rules

Review in Linear

@TheGreatAxios
TheGreatAxios force-pushed the cl-811-structure-system-prompt-into-composable-sections-with-tests branch 2 times, most recently from 20f1f04 to b18ef15 Compare May 29, 2026 07:12
@TheGreatAxios
TheGreatAxios force-pushed the cl-811-structure-system-prompt-into-composable-sections-with-tests branch from b18ef15 to 483e8af Compare May 29, 2026 07:12
@TheGreatAxios

Copy link
Copy Markdown
Collaborator Author

Code Review: System Prompt Refactoring

Summary: Breaks monolithic system prompt into composable sections. Clean separation of tool-call, submit, budget, and plan rules.

Strengths:

  • Each section is a pure function returning a string — excellent testability
  • buildSystemPrompt() and buildChatSystemPrompt() compose correctly
  • Comprehensive test coverage: sections, composition, tool names
  • Commit messages accurately describe the refactor
  • No behavioral changes — functionality preserved

Items to Consider:

  • The prompt sections are tested independently, but verify the composed prompt still functions correctly in the agent loop (end-to-end test?)
  • Some sections (e.g., budget rules) reference specific file sizes/limits — hardcoded or configurable? Document the values
  • Tool list is dynamic via parameter — good. Verify all callers pass the full tool list

GPG Signature: ✅ Verified

@TheGreatAxios
TheGreatAxios merged commit 6732d97 into main May 29, 2026
TheGreatAxios added a commit that referenced this pull request May 31, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request May 31, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request May 31, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request May 31, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request May 31, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request Jul 21, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request Jul 21, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request Jul 21, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request Jul 25, 2026
* Split system prompt into composable sections

* Test prompt section composition
TheGreatAxios added a commit that referenced this pull request Jul 25, 2026
* Split system prompt into composable sections

* Test prompt section composition
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