Skip to content

feat: add system prompt prepend mode for projects#190

Open
crystalin wants to merge 1 commit intomainfrom
feat/prepend-system-prompt
Open

feat: add system prompt prepend mode for projects#190
crystalin wants to merge 1 commit intomainfrom
feat/prepend-system-prompt

Conversation

@crystalin
Copy link
Copy Markdown
Contributor

Summary

  • Adds a new system_prompt_mode column to the projects table ('replace' | 'prepend', default 'replace')
  • In prepend mode, the project's system prompt blocks are placed before the original request blocks instead of replacing them entirely
  • In replace mode (default), existing behavior is unchanged — the project prompt replaces the entire system field

Changes

Database

  • New migration 023-add-system-prompt-mode.ts adds system_prompt_mode VARCHAR(10) NOT NULL DEFAULT 'replace' to the projects table

Shared Package

  • Added SystemPromptMode type ('replace' | 'prepend') to credentials.ts
  • Updated Project and UpdateProjectRequest interfaces with system_prompt_mode field
  • Updated getProjectSystemPrompt() query to return the mode field
  • Updated updateProject() to handle system_prompt_mode updates

Proxy Service

  • Updated applySystemPromptOverride() to support prepend mode
  • Added normalizeSystemToBlocks() helper to convert string system prompts to content block arrays
  • 5 new test cases for prepend mode behavior (12 total tests, all passing)

Dashboard

  • Added mode toggle button (Replace/Prepend) in the project system prompt settings
  • New POST /:projectId/system-prompt-mode endpoint to toggle mode
  • Updated API endpoint to accept and validate system_prompt_mode field
  • Dynamic description text updates based on selected mode

Documentation

  • Updated ADR-034 with prepend mode schema, behavior, and resolved the "all-or-nothing" negative consequence
  • Updated API Reference with new system_prompt_mode field documentation
  • Updated Dashboard Guide with mode selector description
  • Added changelog entry

Test plan

  • TypeScript typecheck passes (bun run typecheck)
  • All 12 system prompt override tests pass (7 replace + 5 prepend)
  • Full test suite: no new failures introduced (18 pre-existing failures in Docker/CLI integration tests)
  • Manual: verify mode toggle in dashboard UI
  • Manual: verify prepend mode correctly combines prompts in proxy
  • Run migration 023 on staging database

🤖 Generated with Claude Code

Projects can now choose to prepend their system prompt before the original
request prompt instead of replacing it entirely. Adds system_prompt_mode
column ('replace'|'prepend') to the projects table with 'replace' as
default, preserving existing behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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