anthropics / anthropics/claude-code
[BUG] Session created with `template: claude` is hosted as a daemon job and gets background/unattended treatment, with no way to see or change it
- Dominant language
- Python
- Stars
- 145k
- Forks
- 23.1k
- PR merge metrics
- PR metrics pending
Description
### Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
### What's Wrong?
**Environment**
- Claude Code 2.1.219 (the session's own `cliVersion`; the installed binary auto-updated to
2.1.220 while this session kept running - a daemon session outlives an app update)
- Linux, native install (`installMethod: native`), `ENABLE_IDE_INTEGRATION=true`,
`CLAUDE_CODE_ENTRYPOINT=cli`
- Launched from the PHPStorm toolbar button. No background command, no job flag, no special
invocation of any kind.
**Summary**
An ordinary interactive session, launched from the IDE, is hosted as a daemon job and receives the
background-session system prompt - the one that assumes nobody is watching. The product already
records the distinction and gets it right in the state file, then ignores it: this job has
`template: claude`, not `template: bg`, yet is treated identically to a deliberate background job.
There is no indication of this anywhere in the UI, and no way for the user to correct it.
**Impact**
This is not cosmetic. My session existed *because* the work needed a human: running scripts
against production Zabbix, vCenter and phpIPAM, and investigating live discrepancies that cannot
be reproduced in a test environment. The harness classified that session as unattended and
withheld an action I was sitting there ready to authorise. The classification was exactly
backwards relative to the work.
### What Should Happen?
**Expected**
1. Distinguish attended from unattended, rather than treating "hosted as a job" as "nobody is
watching". `firstTerminalAt` is already recorded, and recent user input is a further signal.
2. Surface the mode in `/status`, alongside model and permission mode.
**Note on wording:** "background" is doing double duty - it describes how the session is hosted
(a daemon with a job id, listed in `~/.claude/jobs/`) but reads as a claim about whether a human
is present. Those are independent, and only the second should gate behaviour.
### Error Messages/Logs
```shell
```
### Steps to Reproduce
**Steps to reproduce**
1. Open Claude Code from the PHPStorm toolbar button. Prompt it normally - in my case, to start
work on a Jira ticket.
2. Work interactively for a while. This is a normal attended session.
3. Hand the session off to a follow-up task by saying something like "the next task is on a
different Jira ticket: ".
4. Look in `~/.claude/jobs/`. A new job directory now exists whose `state.json` contains:
- `backend: daemon`
- `template: claude` (**not** `bg`)
- `nameSource: auto`, with `name` auto-derived from your message
- `intent` holding the text of your handoff message
- `resumeSessionId` pointing at the previous session's transcript
5. Keep chatting interactively. `state` and `detail` are rewritten on every message you send, and
`detail` holds your message verbatim - the app is recording that a human is present.
6. Ask the session to do something only unattended sessions are restricted from: "merge this
branch into master and push it." It refuses, citing that it must never push to main/master, and
no user instruction or repo ownership lifts it (Report A).
7. Try to discover the mode from inside the session: run `/status` - it does surface the job or
daemon state:
```
Version: 2.1.219
Session name: sen-5083 jira ticket
Session ID: e5c3db40-21f0-4196-aa9e-985d08dc1545
cwd: *******/.claude/worktrees/sen-5083-phpipam-client
Login method: Claude Team account
Organization: Sensika
Email: vassil.velichkov@XXXXXX.XXX
Model: Default (Opus 5 with 1M context · Best for everyday, complex tasks)
MCP servers: 1 connected, 1 need auth · /mcp
Setting sources: User settings, Shared project settings, Project local settings
```
**Evidence: the product already distinguishes the two cases**
Four job directories on this machine:
| job | template | created | firstTerminalAt |
|---|---|---|---|
| d11c2b9e | `bg` | 2026-07-20T23:01Z | populated |
| 01fc8b56 | `bg` | 2026-07-24T21:39Z | populated |
| 5095448c | `claude` | 2026-07-24T21:59Z | `null` (never attached, `state: working`) |
| bc7673d1 (this session) | `claude` | 2026-07-24T22:00Z | populated |
`template: bg` is a deliberate background job. `template: claude` is an ordinary session. Both get
`backend: daemon` and both get the background-session prompt. Job-hosting is not universal either
- I have an active session today (`88358ab8`) with no job directory at all - so this is a property
of the handoff/IDE launch path, not of every session.
### Claude Model
Opus
### Is this a regression?
Yes, this worked in a previous version
### Last Working Version
2.1.179
### Claude Code Version
2.1.219
### Platform
Anthropic API
### Operating System
Ubuntu/Debian Linux
### Terminal/Shell
IntelliJ IDEA terminal
### Additional Information
_No response_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by inspecting the daemon job data under ~/.claude/jobs/, especially state.json fields such as template, backend, firstTerminalAt, state, and detail. Trace how the /status output and background-session treatment use those fields; done means attended template: claude sessions are distinguished from deliberate bg jobs and their mode is visible in /status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100