Skip to content

feat(cli): add --output-schema flag - #17276

Closed
Sceptyre wants to merge 28 commits into
anomalyco:devfrom
Sceptyre:feature/run-json-schema
Closed

Sceptyre wants to merge 28 commits into
anomalyco:devfrom
Sceptyre:feature/run-json-schema

Conversation

@Sceptyre

@Sceptyre Sceptyre commented Mar 13, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #9320
Closes #10456

Type of change

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

What does this PR do?

This PR extends the output schema SDK feature added in a previous PR to the opencode run cli.
This adds the flags --output-schema to allow defining the json-schema contents
The value for --output-schema can be either a json compatible string or a path to a file containing a json compatible string.

How did you verify your code works?

$ bun run dev run -- "hello world" --output-schema "{\"type\":\"object\",\"properties\":{\"is_hello_world\":{\"type\":\"boolean\"}},\"required\":[\"is_hello_world\"]}"
{"is_hello_world":true}

Screenshots / recordings

If this is a UI change, please include a screenshot or recording.

Checklist

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

If you do not follow this template your PR will be automatically rejected.

@Sceptyre
Sceptyre marked this pull request as ready for review March 13, 2026 02:40
@Sceptyre Sceptyre changed the title feat(9320): add --json and --json-schema flags feat(cli): add --json and --json-schema flags Mar 13, 2026
@Sceptyre
Sceptyre marked this pull request as draft March 18, 2026 18:36
@Sceptyre Sceptyre changed the title feat(cli): add --json and --json-schema flags feat(cli): add --output-schema flag Mar 18, 2026
@Sceptyre
Sceptyre marked this pull request as ready for review March 20, 2026 19:34
@Sceptyre

Copy link
Copy Markdown
Author

@rekram1-node @adamdotdevin
Apologies for the direct pings, unsure on how to request feedback on a PR. Would love some guidance!

Thank you!

@deniz-hofmeister

Copy link
Copy Markdown

I'd like to add my support for this feature.
--output-schema would enable structured output parsing directly from opencode run, which is currently a gap compared to Claude Code's --output-format json with schema constraints.
Feature parity would be nice.

@thdxr

thdxr commented Oct 10, 2026

Copy link
Copy Markdown
Member

This branch has been upgraded to V2. We're no longer taking PRs for V1. If you think this is still relevant, please port it over and open it for V2.

— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Labels

None yet

Projects

None yet

3 participants