Claude CodeSoftwareShipping codeAI score · 82/100AI-assisted edit · no obvious prompt-injection riskX

Check git log first after resuming a Claude Code session

Scenario: Claude Code session resumes after crash → query last git commit → verify state before continuing

Some experienceStepsPromptTip
Who
Developers using Claude Code
You get
Prevent the AI from redoing finished work and conflicting with its own prior changes
You need
Git

Constraints

After a Claude Code session is interrupted by a crash or pause and then resumed, first have it check the git log to confirm the last commit state before asking it to continue any coding or modifications. Applies to projects already using git.

What they did

Author yuan_minh5988, while using Claude Code, encountered session crashes or resumes. They found that without first confirming state, Claude Code would redo work it had already completed, then conflict with its own prior changes.

How it went

The author reported this practice saved them twice in one week (author_report). By checking git log first, Claude Code can understand the state of the last commit and avoid redundant work.

Worth knowing

Prerequisite: project initialized with git and has at least one commit. If there are uncommitted changes in the working directory, git log still shows the last commit; additional git status confirmation may be needed. Source did not provide Claude Code version. Not tested by this site; effects are author-reported.

Steps

  1. Query git history after session resume

    When a Claude Code session is interrupted due to a crash, terminal closure, or other reason and then resumed, before asking it to continue any coding or modification work, send the prompt to have it check the git log and confirm the content of the most recent commit. Wait for it to return the commit information, then continue subsequent tasks based on that state.

    Execution prompt · Source text。Claude Code chat input; first message after session resume

    check git log for your last commit before you touch anything

Prompt you can copy

Reference prompt · Source text。Confirm the destination, input variables and output format before use.

This block is the prompt. Ads are never placed here.

check git log for your last commit before you touch anything

Enter the English prompt from the step directly into Claude Code after resuming the session

Source

Claude Code 中断或恢复会话后,第一句先让它查 git log 里自己的上一次提交 · yuan_minh5988 · X · 2026-10-22T13:05:43.000Z

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related