spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / is-checkpointing / is-checkpointing.ts
20 lines · 794 BRaw
1import type { Settings } from 'claude-code'
2
3/**
4 * Whether the session checkpoints Claude's edits, read as the built-in
5 * reads it: the setting on unless set false, the variable unset or falsy.
6 *
7 * The built-in panel opens on an edit only through a checkpoint, so with
8 * checkpointing off its first-edit open never happens; `/diff` still opens.
9 *
10 * @param settings the merged settings (`$.settings.read()`)
11 * @param disabling `CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING` as `$.env.get`
12 * answers it
13 * @returns false when either turns checkpointing off
14 */
15export const isCheckpointing = (
16 settings: Settings,
17 disabling: string | undefined,
18): boolean =>
19 settings.fileCheckpointingEnabled !== false &&
20 !['1', 'true', 'yes', 'on'].includes((disabling ?? '').trim().toLowerCase())