講座 › 分野3 Claude Codeの設定とワークフロー
3.6 CI/CDへの統合
配点 3.3%CI/CD integration
CIでは、対話なしの形で動かし、結果は機械が読める形で受け取る。コードを書いた会話とは別の会話で、レビューする。
未読
対話なしで動かす:-p 読了

CIのような自動の処理では、-p(--print)を付けて、対話なしの形で動かします。付けないと、入力待ちで処理が止まります。
出典:Run Claude Code programmatically
To run Claude Code in non-interactive mode, pass -p with your prompt and the CLI options you need:https://code.claude.com/docs/en/headless.md(取得 2026-11-20)
出典:Run Claude Code programmatically
Add the -p (or --print) flag to any claude command to run it non-interactively.https://code.claude.com/docs/en/headless.md(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The -p (or --print) flag for running Claude Code in non-interactive mode in automated pipelineshttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
機械が読める出力:JSON とスキーマ 読了

--output-format に json を、--json-schema にスキーマを指定すると、決められた形の結果が structured_output の欄に入ります。指摘を整理した形式で受け取り、プルリクエストへのインラインのコメントとして、自動で投稿できます。
出典:Run Claude Code programmatically
To get output conforming to a specific schema, use --output-format json with --json-schema and a JSON Schema definition.https://code.claude.com/docs/en/headless.md(取得 2026-11-20)
出典:Run Claude Code programmatically
The response includes metadata about the request (session ID, usage, etc.) with the structured output in the structured_output field.https://code.claude.com/docs/en/headless.md(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Using --output-format json with --json-schema to produce machine-parseable structured findings for automated posting as inline PR commentshttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Claude Code GitHub Actions
Claude posts each review on the pull request itself, as an inline comment on each issue it finds or as one summary comment when it finds none.https://code.claude.com/docs/en/github-actions.md(取得 2026-11-20)
プロジェクトの文脈は CLAUDE.md で渡す 読了

テストの標準、使える準備用データ、レビューの基準は、CLAUDE.md に書いておきます。CIから呼ばれるClaude Codeが、それを読んで動きます。テストの質が上がり、価値の低い出力が減ります。
出典:Best practices for Claude Code
How to confirm work in this repo: the exact test, typecheck, and lint commands, and how to run a single test filehttps://code.claude.com/docs/en/best-practices.md(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Documenting testing standards, valuable test criteria, and available fixtures in CLAUDE.md to improve test generation quality and reduce low-value test outputhttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
書いた本人とは別の会話でレビューする 読了

コードを生成した同じ会話は、自分の変更の見直しが甘くなります。独立した、新しい会話でレビューすると、作った理屈に引きずられません。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Session context isolation: why the same Claude session that generated code is less effective at reviewing its own changes compared to an independent review instancehttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Best practices for Claude Code
reviews the diff in a fresh subagent that never saw your conversation. It isn't swayed by the reasoning that produced the code.https://code.claude.com/docs/en/best-practices.md(取得 2026-11-20)
再実行で、同じ指摘を重ねない 読了

新しいコミットのあとに再実行するときは、前回の指摘を文脈に入れ、新しい指摘と、まだ直っていない指摘だけを報告させます。テストの生成では、既存のテストを渡して、同じ場面の提案を避けます。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Including prior review findings in context when re-running reviews after new commits, instructing Claude to report only new or still-unaddressed issues to avoid duplicate commentshttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Providing existing test files in context so test generation avoids suggesting duplicate scenarios already covered by the test suitehttps://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)
試験のポイント
- CIでは -p で対話なしにする。入力待ちの停止を防ぐ。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
The -p (or --print) flag for running Claude Code in non-interactive mode in automated pipelines
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - --output-format json + --json-schema で、指摘を機械が読める形で受け取る。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Using --output-format json with --json-schema to produce machine-parseable structured findings for automated posting as inline PR comments
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20) - レビューは、書いた会話とは別の会話で。再実行時は前回の指摘を渡す。
出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Session context isolation: why the same Claude session that generated code is less effective at reviewing its own changes compared to an independent review instance
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)出典:Claude Certified Architect – Foundations Exam Guide v1.0(英語)
Including prior review findings in context when re-running reviews after new commits, instructing Claude to report only new or still-unaddressed issues to avoid duplicate comments
https://everpath-course-content.s3-accelerate.amazonaws.com/instructor…(取得 2026-11-20)