- Claude Code answers an unanswered
AskUserQuestionon its own after 60 seconds. To stop that, setCLAUDE_AFK_TIMEOUT_MSto a very large number in your~/.claude/settings.jsonenvblock, then restart. - To keep it but wait longer, set the same variable to the delay you want in milliseconds (e.g.
600000for 10 minutes). CLAUDE_AFK_COUNTDOWN_MScontrols the on-screen countdown, default 20 seconds.- Both are undocumented and sit behind a rollout flag, so the exact default may vary by account.
If you want to disable Claude Code's AFK auto-answer and skip the explanation, here's the whole fix. Open ~/.claude/settings.json and add this to the env block:
{
"env": {
"CLAUDE_AFK_TIMEOUT_MS": "2147483647"
}
}
That's the maximum 32-bit integer, roughly 24 days, so in practice the timer never fires and Claude Code waits for your answer like it used to. Restart Claude Code so the variable is picked up, and you're done. The rest of this page explains what you just changed and the other values worth knowing.
What this actually turns off
In v2.1.198 Anthropic added a feature internally called AFK mode (away from keyboard). When an AskUserQuestion dialog goes unanswered, a countdown runs, and when it expires Claude Code resolves the dialog itself and tells the model to proceed on its best judgment. Handy for unattended runs, annoying if you like to sit and think about the question. If you want the full background on how it works and how I found it, I wrote that up separately: the undocumented AFK mode teardown.
There is no setting for this in the UI and no flag in --help. The only controls are two environment variables baked into the binary.
The two variables
| Variable | Default | What it does |
|---|---|---|
| CLAUDE_AFK_TIMEOUT_MS | 60000 | Milliseconds to wait before auto-answering. Large value = effectively disabled. |
| CLAUDE_AFK_COUNTDOWN_MS | 20000 | Milliseconds of visible countdown before the timeout. Capped at the timeout value. |
Never auto-answer
"CLAUDE_AFK_TIMEOUT_MS": "2147483647"
Wait 10 minutes instead of 1
"CLAUDE_AFK_TIMEOUT_MS": "600000"
Keep the timeout, shorten the countdown
"CLAUDE_AFK_COUNTDOWN_MS": "5000"
The values are strings in settings.json, and they're milliseconds, not seconds. That's the mistake to avoid: "60" is 60 milliseconds, not 60 seconds.
Confirm it worked
Two quick checks. First, that the variable is set in your environment. Second, that your build even has the feature. Run this against your installed binary (adjust the path to wherever your installer keeps versioned builds):
# Is the AFK feature in your build? (adjust the version path to yours)
strings ~/.local/share/claude/versions/2.1.198 | grep -c CLAUDE_AFK_TIMEOUT_MS
# Did your settings.json override reach the shell Claude Code runs in?
echo "$CLAUDE_AFK_TIMEOUT_MS"
If the first command prints 0, your version predates the feature and there's nothing to disable. If it prints a positive number, the feature is present and the env var will control it. The second command should echo whatever you set (note that a value in settings.json only appears in sessions Claude Code launched after you saved it).
Setting it per-project? Put the env block in the project's .claude/settings.json instead of your home one. Handy when you want long-running unattended sessions to keep AFK on, but your interactive work to leave it off.
One caveat
These variables are undocumented, and the feature is gated by a server-side rollout flag. That means two things. The 60-second default is what's in the binary, but a rollout cohort could see different behavior. And because none of this is official, Anthropic can rename or change the variables in a future version without a note. If an update makes your override stop working, re-run the strings check above to see whether the variable names changed.
Why you might leave it on
If you run Claude Code unattended, through a delegated session, an overnight job, or a remote channel, AFK mode is the thing that keeps a clarifying question from wedging the whole run forever. In that setup you want it on, maybe with a longer timeout. The one rule that makes it safe: write your AskUserQuestion prompts so the first option is the conservative, reversible one, because that's effectively what an absent user picks when the timer runs out.
Common questions
Do I need to restart Claude Code?
Yes. Environment variables in settings.json are read when a session starts, so a running session won't pick up the change. Save the file, quit, and start a fresh session.
Does this affect my teammates?
Only if you put it in a shared, checked-in .claude/settings.json. A value in your home ~/.claude/settings.json is yours alone. For a repo you share, decide deliberately whether unattended runs there should keep the timeout.
Can I set it with a shell export instead?
Yes. export CLAUDE_AFK_TIMEOUT_MS=2147483647 before launching Claude Code works the same way, which is handy for the launcher scripts that start delegated or headless sessions. The settings.json route just makes it stick without remembering to export.
It's still auto-answering. What now?
Two usual causes. The session was already running when you saved the change, so restart it. Or the variable name shifted in a newer build, since none of this is documented, so re-run the strings check above and grep for AFK to see the current names.