대화형 실행과 헤드리스 실행
대화형 세션과 스크립트 기반 비대화형 실행을 비교합니다
대화형 실행과 헤드리스 실행은(는) CoddyKit의 무료 Claude Architect 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Claude Architect 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Two Ways to Run Claude Code
Claude Code runs in two fundamentally different modes, and choosing the right one is a real architectural decision.
- Interactive: a conversational session. You type, Claude responds, you steer, it asks for approvals. A human is in the loop.
- Headless (non-interactive): a single scripted invocation that runs to completion with no human present. Built for pipelines and automation.
Same engine, very different control model. This lesson shows when each one wins.
The Headless Flag
You switch into headless mode with -p (also written --print). It runs the prompt once, prints the result, and exits. No back-and-forth, no TTY required.
This is the required form for CI/CD pipelines: there is no human to answer prompts inside a build job, so an interactive session would simply hang.
# Interactive: opens a conversational session
claude
# Headless: runs once and exits (required in pipelines)
claude -p "Review the staged diff and flag correctness bugs"Parseable Output
Interactive output is for humans to read. Headless output is for machines to parse. Use --output-format json so a downstream step can act on the result programmatically.
Pair it with a JSON Schema so the structure is guaranteed and your pipeline never breaks on free-form prose.
claude -p "List failing test files and the root cause for each" \
--output-format json \
--output-schema ./schemas/review.json > review.json
# A later CI step reads review.json and decides pass/failWho Drives the Decisions?
The deepest difference is who steers.
- Interactive: the human course-corrects mid-task, approves edits, and resolves ambiguity by being asked.
- Headless: no one is there to ask. The prompt must be self-contained, the success criteria explicit, and ambiguous input handled by the prompt itself, not by a follow-up question.
If your task genuinely needs a human judgment call partway through, headless is the wrong choice.
Plan Mode Is Interactive
Plan mode belongs to the interactive world. You use it for large changes, multiple possible approaches, or architectural decisions: Claude explores and proposes a plan, then waits for your approval before editing.
That approval gate is a human checkpoint. It has no meaning in a headless run, where there is no one to approve. For single-file fixes or a clear stack trace, you skip plan mode and execute directly anyway.
Headless in CI: Review on Every PR
A classic headless use case: an automated code review on every pull request. The job runs -p, emits JSON, and a script turns findings into comments or a gate.
Crucially, run this review in an isolated session so it is not biased by any generation context. Fresh-instance review beats same-session self-review, where the author keeps its own reasoning and won't challenge itself.
# .github/workflows/review.yml (step)
- name: Claude review
run: |
claude -p "$(cat .ci/review-prompt.md)" \
--output-format json > findings.json
node .ci/post-comments.js findings.jsonMinimize False Positives
A headless reviewer that cries wolf gets muted. Give it explicit criteria instead of vague instructions: "flag a comment only when it contradicts the code" beats "be more precise".
When re-running on a later push, include the prior results and report only new or unfixed issues, so the same noise isn't repeated on every commit.
claude -p "Flag an issue ONLY when it changes runtime behavior or breaks a test. \
Here are last run's findings: $(cat prev-findings.json). \
Report only NEW or still-unfixed issues." \
--output-format jsonHeadless Is Not the Batch API
Don't confuse a headless blocking check with the Message Batches API. They solve different problems.
- Headless
-pin CI: synchronous, returns now, gates a merge. - Batch API: 50% cheaper, up to a 24h window, no latency SLA, and no multi-turn tool calling.
Use Batch for non-blocking overnight jobs like reports or audits, never for a pre-merge or time-sensitive check that must answer immediately.
Sessions Belong to Interactive Work
Interactive work is conversational and resumable. --resume <name> continues a named session; fork_session branches from a shared point to try alternatives.
One caution: resumed tool results can be stale if the codebase changed since. Sometimes a fresh session seeded with a structured summary is better than resuming an out-of-date one.
# Continue a named conversation later
claude --resume refactor-auth
# Branch from a shared point to explore an alternative
# (fork_session) without disturbing the original threadConfiguration Shared by Both Modes
Both modes read the same project configuration, so a well-set-up repo behaves consistently whether a human or a pipeline invokes it.
- ./CLAUDE.md (project-level, shared via VCS) carries standards into every run.
- .claude/skills/ and commands give reusable, scoped behaviors.
Note: user-level ~/.claude/CLAUDE.md is personal and NOT shared via VCS, so your CI runner won't have it. Put anything the headless job depends on in the project scope.
# Headless CI relies on project-scope config, not your machine's:
# ./CLAUDE.md -> shared via VCS (CI sees it)
# .claude/skills/ -> shared via VCS (CI sees it)
# ~/.claude/CLAUDE.md -> personal only (CI does NOT see it)A Decision Checklist
When picking a mode, ask:
- Is a human present to approve and steer? Yes -> interactive. No -> headless.
- Does a script need to parse the result? Yes -> headless with
--output-format json. - Is it a blocking, time-sensitive check? Use synchronous headless, not Batch.
- Large or architectural change needing approval first? Interactive plan mode.
- Automated PR review? Headless, isolated session, explicit criteria.
Match the mode to who is in the loop and what consumes the output.
Quick Check
Apply what you've learned to a realistic pipeline decision.
Recap: Interactive vs Headless
Key takeaways:
- Interactive = conversational, human-in-the-loop; supports plan mode approvals and resumable/forkable sessions.
- Headless =
-p/--print, runs once and exits; required for CI/CD where no human is present. - Add --output-format json (plus a schema) for machine-parseable results.
- Automated review should run in an isolated session with explicit criteria, reporting only new/unfixed issues.
- Both modes share project-scope config (./CLAUDE.md, .claude/), but not personal ~/.claude config.
- Headless blocking checks are NOT the Batch API: Batch is cheaper but has no latency SLA and no multi-turn tool calling.
자주 묻는 질문
“대화형 실행과 헤드리스 실행” 강의는 무료인가요?
네 — “대화형 실행과 헤드리스 실행” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Claude Architect 강의 전체를 잠금 해제할 수 있습니다. Claude Architect 강의에는 총 4개의 강의가 포함되어 있습니다.
“대화형 실행과 헤드리스 실행”에서 뭘 배우나요?
대화형 세션과 스크립트 기반 비대화형 실행을 비교합니다 브라우저에서 직접 실행하는 실습 코드로 Claude Architect을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Claude Architect을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Claude Architect은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“대화형 실행과 헤드리스 실행” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Claude Architect 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Claude Architect 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Claude Code란 무엇인가
- 대화형 실행과 헤드리스 실행
- Read / Edit / Write 루프
- 메모리 및 Compact 명령