# Example: schema-validated PR review verdict via `claude_args` + `structured_output`. # # Instead of having the agent write its verdict to a file, this asks Claude for a # result that conforms to a JSON Schema and reads it back from the action output. # The default-installed Claude CLI (2.1.160) supports `--json-schema`; the # action reads the schema file below and passes it to the CLI inline, so the # file-path form works out of the box (see README → "Structured output"). If # you consume this action through a pre-baked runner image # (path_to_claude_code_executable), that image's CLI must still support the # `--json-schema` flag. name: Claude PR Review (structured output) on: pull_request: types: [opened, synchronize] jobs: review: runs-on: ubuntu-latest permissions: contents: read pull-requests: write issues: write steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 # The schema the verdict must conform to. Using a file (rather than an # inline string) keeps the value free of spaces and `$` characters, so a # schema with $ref/$defs survives shell tokenization intact. - name: Write review schema shell: bash run: | mkdir -p .gitea cat > .gitea/review-schema.json <<'JSON' { "type": "object", "additionalProperties": false, "required": ["decision", "summary"], "properties": { "decision": { "type": "string", "enum": ["approve", "request_changes", "comment"] }, "summary": { "type": "string" } } } JSON - name: Run Claude review id: review uses: ryan/claude-code-gitea-action@gitea with: gitea_token: ${{ secrets.GITEA_TOKEN }} anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} direct_prompt: | Review the changes in this pull request and return your verdict strictly matching the provided JSON schema. claude_args: --json-schema ${{ github.workspace }}/.gitea/review-schema.json - name: Act on the verdict shell: bash env: VERDICT: ${{ steps.review.outputs.structured_output }} run: | echo "Decision: $(echo "$VERDICT" | jq -r '.decision')" echo "Summary: $(echo "$VERDICT" | jq -r '.summary')"