Skip to content

Add typed JSON output to app security instructions - #8965

Open
jek wants to merge 3 commits into
app-security/support-json-schema-recordfrom
app-security/support-json-schema-instructions
Open

jek wants to merge 3 commits into
app-security/support-json-schema-recordfrom
app-security/support-json-schema-instructions

Conversation

@jek

@jek jek commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

app security instructions prints the coding-agent workflow as Markdown, or copies or writes it. Callers using --json need the instructions inside a single result, and check (later in this stack) will return them the same way.

WHAT is this pull request doing?

Adds --json to app security instructions:

  • By default it returns {"status": "success", "app": {…}, "resultsDirectory": "…", "instructions": {"content": "<Markdown>", "copied": false}}. With --copy, copied is true. The results directory may not exist yet, because the instructions start by running check.
  • With --write <file>, stdout holds only {"path": "/abs/file.md", "format": "markdown"}, as with doc fetch.

Commits:

  1. Split the instructions into building, delivering (copy or write) and presenting, so check can reuse them. No behaviour change.
  2. Add --json.
  3. Report clipboard failures as errors. When the clipboard tool is missing (xsel on Linux, for example), --copy used to fail as an unexpected error with a stack trace, reported as a bug. It now fails as an error with the code clipboard-unavailable and suggests printing or --write instead. It has its own patch changeset.

How to manually test your changes?

Build once and run the local CLI directly, so nothing else reaches stdout:

pnpm nx build cli
alias shopify-dev="node $PWD/packages/cli/bin/dev.js"
shopify-dev app security instructions --path <app> --json
shopify-dev app security instructions --path <app> --copy --json             # copied: true; the clipboard holds content
shopify-dev app security instructions --path <app> --write /tmp/instructions.md --json

To see the clipboard error on macOS, hide pbcopy, then run --copy with and without --json:

mkdir -p /tmp/no-pbcopy && ln -sf "$(command -v node)" /tmp/no-pbcopy/
PATH=/tmp/no-pbcopy node packages/cli/bin/dev.js app security instructions --path <app> --copy --json

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

jek added 3 commits October 20, 2026 16:43
`instructions` and `check` now generate the instructions, copy them or
write them to a file, and print them or confirm the delivery as three
separate steps. The JSON output of both commands will include the
instructions instead of printing them, and reuse the first two steps.
The text output doesn't change.
`--json` prints the instructions, whether they were also copied to the
clipboard, the app they are for, and its results directory. That
directory may not exist yet: the instructions start by running `check`,
which creates it. With `--write`, stdout holds only the written file's
path and format, as for `doc fetch`.

The instructions' JSON definition is shared, so that `check` can
include it in its result as well.
A failed copy of the app security check instructions surfaced as an
unexpected error, reported as a bug with its stack. It now aborts with
the `clipboard-unavailable` code and the clipboard tool's message, and
suggests printing the instructions or writing them to a file instead.

`check` copies through the same step, so it aborts the same way.
@jek
jek added this pull request to stack #8969 October 21, 2026 00:00
@github-actions github-actions Bot added the Area: @shopify/cli @shopify/cli package issues label Oct 21, 2026
@jek jek changed the title app security/support json schema instructions Add typed JSON output to app security instructions Oct 21, 2026
@jek
jek marked this pull request as ready for review October 21, 2026 13:50
@jek
jek requested review from a team as code owners October 21, 2026 13:50

This branch has not been deployed

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

Labels

Area: @shopify/cli @shopify/cli package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant