claude-cli-session
Claude CLI Session
Use this skill when the user wants Claude Code to continue work through a pinned project session instead of starting a fresh session every time.
Use the project-root .claude-cli-session-id file as the primary source of truth for the session to resume.
The main user task must never run without an active session ID.
Do not use wrapper scripts. Run Claude CLI directly.
Default to --permission-mode acceptEdits for edit-capable automated runs unless the user explicitly asks for a different permission mode.
Workflow
- Read
<project-root>/.claude-cli-session-idfirst. - If the file exists and contains a valid UUID session ID, use that value for the real Claude command.
- If the file is missing or empty, generate a new UUID, write it into
.claude-cli-session-id, and use it to bootstrap a fresh Claude session with--session-id. - When bootstrapping a brand-new session, use a short bootstrap prompt that tells Claude to inspect the current directory and get ready to continue work in this project.
- If bootstrap fails and
.claude-cli-session-idstill does not contain an active session ID, do not run the main user prompt. Report the failure and stop. - Only after
.claude-cli-session-idcontains an active session ID, run the real user task with--resume. - Keep the user's prompt text exact unless they explicitly ask you to rewrite it.
- If the user explicitly provides a different Claude session ID, update
.claude-cli-session-idto that value before running the next Claude command. - If the user wants the exact Claude output, relay it faithfully. Otherwise, summarize the relevant answer from the command output.
Command Pattern
Use:
claude -p --resume "<session-id>" --output-format stream-json --permission-mode acceptEdits "<prompt>"
If there is no session yet, use this only as a bootstrap step:
claude -p --session-id "<uuid>" --output-format stream-json --permission-mode acceptEdits "Inspect the current directory and get ready to continue work in this project."
If the user explicitly wants to drive Claude Code through Ollama, use:
ollama launch claude --model "<model>" -- -p --resume "<session-id>" --output-format stream-json --permission-mode acceptEdits "<prompt>"
If there is no session yet in the Ollama-driven flow, generate a UUID, write it to .claude-cli-session-id, then bootstrap with:
ollama launch claude --model "<model>" -- -p --session-id "<uuid>" --output-format stream-json --permission-mode acceptEdits "Inspect the current directory and get ready to continue work in this project."
File Rules
- The session file must live at
<project-root>/.claude-cli-session-id. - The file should contain only the session ID string and a trailing newline.
- Treat the file as the project's pinned Claude conversation.
- The real user prompt must be executed only after this file contains an active session ID.
Notes
--resumerequires an existing session. If you do not have one yet, bootstrap first with--session-id.--session-idmust be a valid UUID.- No main task execution without a session ID. Bootstrap comes first; if it fails, stop.
- Prefer
--output-format stream-jsonfor machine-readable output and reliable session-oriented workflows. - If the user asks what Claude previously saw or said, use the active session ID with a direct prompt such as
What was my last message to you?
More from erdinccurebal/cli-session-skills
gemini-cli-session
Use when the user wants the primary agent to call Gemini CLI directly while preserving an existing Gemini conversation history. Read the session ID from a project-root `.gemini-cli-session-id` file when available; otherwise recover the latest project session from local Gemini history or create a new session, then persist that ID. Use `--approval-mode auto_edit` by default so Gemini CLI can write files with its own edit tools. Covers `-r <session-id>`, `-p`, `-m gemini-3-flash-preview`, and `stream-json` output handling.
5codex-cli-session
Use when the user wants Codex CLI session continuity across repeated non-interactive runs. Read the session ID from a project-root `.codex-cli-session-id` file when available; otherwise bootstrap a new Codex session, persist the new session ID, and then run the real task with `codex exec resume`. Covers session continuity, `--json`, `-m`, and project-scoped session pinning.
4