Skip to content

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

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

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.json instructions, 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
Rexarrior force-pushed the system-prompt-export branch from 600aa5a to d65e04a Compare August 28, 2026 20:03
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant