Cmd. /background, /bg
현재 세션을 background agent로 분리해 터미널을 비우고 Agent View에서 관리하는 명령
핵심 요약
/background(별칭/bg)는 현재 대화를 background agent로 분리해 터미널을 비우며, 프롬프트를 함께 넘기면 분리 전 마지막 지시를 한 번 더 전달합니다.- 분리된 세션은 별도 supervisor 프로세스가 계속 돌리므로 터미널을 닫아도 작업이 이어지며,
claude agents(Agent View)로 모니터링합니다. - background 세션은 파일을 쓰기 전
.claude/worktrees/아래 격리된 git worktree로 이동하며, Agent View에서 삭제하면 그 worktree와 미커밋 변경까지 사라집니다. - 실행 중인 subagent·monitor·background command가 있으면
/bg분리 시 이전되지 않고 Claude가 확인을 먼저 요청합니다. - Agent View는 research preview로 v2.1.139 이상이 필요하며, 각 세션이 구독 사용량을 독립적으로 소비합니다.
명령어 원본 선언
/background [prompt]
/bg [prompt]공식 설명 요약
공식 문서의 표현은 다음과 같습니다.
Detach the current session to run as a background agent and free this terminal. Pass a prompt to send one more instruction before detaching. Monitor the session with
claude agents. Alias:/bg
/background(별칭 /bg)는 현재 대화를 background agent로 분리해 터미널을 다시 쓸 수 있게 해줍니다. 프롬프트를 함께 넘기면 분리 직전에 마지막 지시를 한 번 더 보냅니다. 분리된 세션은 별도의 supervisor 프로세스가 계속 돌리므로 터미널을 닫아도 작업이 이어집니다.
분리된 세션은 claude agents(Agent View)로 모니터링하며, 셸에서는 claude attach, claude logs, claude stop 등으로 관리합니다.
최소 지원 버전
- Agent View(background agent)는 research preview이며 Claude Code v2.1.139 이상이 필요합니다. (
claude --version으로 확인) worktree.bgIsolation설정은 v2.1.143 이상에서 동작합니다.- v2.1.144부터 background 세션은
/resume세션 선택기에bg표시와 함께 나타납니다.
사용법
# 현재 대화를 그대로 background로 전환하면서 마지막 지시를 추가
/bg run the test suite and fix any failures# 셸에서 바로 새 background 세션 시작 + 표시 이름 지정
claude --bg --name "flaky-test-fix" "investigate the flaky SettingsChangeDetector test"# 모델을 호출하지 않고 셸 명령만 background job으로 실행
claude --bg --exec 'pytest -x'/bg로 백그라운드 전환할 때 Claude가 응답 중이었다면 그 응답은 background 세션에서 계속됩니다. 분리하고 나면 Claude가 short ID와 관리용 명령을 출력합니다.
backgrounded · 7c5dcf5d · flaky-test-fix
claude agents list sessions
claude attach 7c5dcf5d open in this terminal
claude logs 7c5dcf5d show recent output
claude stop 7c5dcf5d stop this session좋은 사용 예
- 긴 테스트/빌드/조사 작업을 터미널에서 분리해 계속 실행
- 여러 repository 또는 worktree에서 병렬 조사 진행
claude --bg --exec로 shell command를 Agent View row로 띄워 attach 없이 관찰
비슷한 명령어 추천
| 명령어 | 차이점 | 언제 선택 |
|---|---|---|
/bg | /background의 별칭 — 현재 세션을 background로 전환 | 대화 맥락을 이어서 오래 돌릴 때 |
claude --bg | 셸에서 바로 background 세션 시작 | 새 작업을 독립 세션으로 시작할 때 |
claude agents | background 세션 목록/관리(Agent View) | attach, peek, rename, pin, stop이 필요할 때 |
/tasks | 현재 세션 안에서 실행 중인 background 작업 나열 (별칭 /bashes) | 세션을 분리하지 않고 진행 중 작업을 볼 때 |
/stop | attach 중인 background 세션을 종료 | 분리된 세션을 끝낼 때 |
활용 사례
- 빈 프롬프트에서
←(왼쪽 화살표)를 누르면 현재 세션을 background로 보내면서 Agent View를 한 번에 여는 단축 동작이 됩니다. (/config의leftArrowOpensAgents로 끌 수 있음) - 원래 실행 시 지정한
--mcp-config,--settings,--add-dir,--plugin-dir,--fallback-model,--allow-dangerously-skip-permissions같은 구성 플래그는 background 세션으로 그대로 이어집니다. - 실행 중인 subagent, monitor, background command는
/bg분리 시 이전 세션에서 넘어오지 않으며, 이런 작업이 있으면 Claude가 확인을 먼저 요청합니다.
주의사항
/bg분리 시 subagent·monitor·background command가 실행 중이면 새로 시작되는 프로세스로 이전되지 않습니다.Cannot open agents — N background task(s) running안내가 뜨면/tasks로 확인 후/bg로 포기를 확정하세요.- background 세션은 파일을 쓰기 전에
.claude/worktrees/아래의 격리된 git worktree로 이동합니다. (이미 worktree 안이거나 git 저장소가 아니면 생략) worktree.bgIsolation: "none"(v2.1.143+)은 worktree가 부적합한 repository에서만 제한적으로 사용하세요. 이 경우 작업 복사본을 직접 수정합니다.- Agent View에서 세션을 삭제(
Ctrl+X두 번)하면 Claude가 만든 worktree와 그 안의 커밋되지 않은 변경까지 함께 삭제되므로, 보존할 변경은 먼저 commit/push하세요. (셸의claude rm은 변경이 있는 worktree를 남겨 두고 경로를 출력합니다.) - background 세션은 로컬 머신에서 실행됩니다. 절전 상태는 견디지만 머신을 종료하면 멈추고 다음 실행 시 failed로 표시됩니다(attach/peek/reply하면 재개).
- 각 background 세션은 구독 사용량을 독립적으로 소비하므로 병렬 실행 수에 주의하세요.
출처
- Commands: https://code.claude.com/docs/en/commands
- Agent View: https://code.claude.com/docs/en/agent-view