Skip to content

feat(opencode): add system prompt debug command - #39905

Open
Rexarrior wants to merge 1 commit into
anomalyco:devfrom
Rexarrior:system-prompt-export
Open

feat(opencode): add system prompt debug command#39905
Rexarrior wants to merge 1 commit into
anomalyco:devfrom
Rexarrior:system-prompt-export

Conversation

@Rexarrior

Copy link
Copy Markdown

Issue for this PR

Related to #24990, #39033, and #33333.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a local CLI debug command:

opencode debug prompt

The command prints the resolved effective system prompt for the current project, agent, and model. It supports optional --agent and --model flags.

This is useful when debugging prompt-affecting customization layers such as AGENTS.md, opencode.jsoninstructions, skills, MCP instructions, custom agents, and experimental.chat.system.transform plugins.

The implementation uses the same existing system prompt services used by normal request assembly:

  • SystemPrompt.provider(model) for the model-family base prompt
  • SystemPrompt.environment(model) for environment context
  • Instruction.system() for AGENTS.md and configured instruction files
  • SystemPrompt.mcp(agent) for MCP instructions
  • SystemPrompt.skills(agent) for the available skills block
  • experimental.chat.system.transform for plugin transformations

This is intentionally narrower than a full context dump or export feature. It does not persist anything to opencode.db, does not change transcript export behavior, does not add a TUI surface, and does not dump the full request/message array.

How did you verify your code works?

  • Ran bun typecheck in packages/opencode
  • Ran bun --conditions=browser ./src/index.ts debug prompt --help
  • Ran bun --conditions=browser ./src/index.ts --pure debug prompt --model opencode/big-pickle
  • Verified the real command output included the environment block, instruction files, and available skills block
  • Ran bun run build --single --skip-install --skip-embed-web-ui
  • Ran built binary smoke test: dist/opencode-darwin-arm64/bin/opencode --version
  • Ran built binary command check: dist/opencode-darwin-arm64/bin/opencode debug prompt --help
  • Pre-push hook ran bun turbo typecheck successfully

Screenshots / recordings

N/A. CLI-only change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@Rexarrior

Copy link
Copy Markdown
Author

Hi! Friendly bump on this PR. The implementation is locally verified, but the required CI workflows are still waiting for maintainer approval. Could someone approve them and take a look when convenient?

@Rexarrior
Rexarriorforce-pushed the system-prompt-export branch from 592ebb8 to 600aa5aCompareAugust 21, 2026 09:42
Sign up for freeto 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

@Rexarrior