A safe start begins before the prompt
Claude Code works with a live repository, so the first check is not the task wording but the state of the workspace. Make sure the correct directory is open, local changes are understood, and there is a separate point of return for new work.
A Git baseline is a recorded state that you can compare Claude’s result against. The repository does not have to be completely clean, but you must be able to explain every existing diff before starting a new task.
| Check | Why it matters |
|---|---|
| Current directory | Avoid confusing the needed repository with an old or test copy |
| Git status | See changes that already exist before starting Claude |
| Separate branch | Isolate the experiment and simplify rollback |
.gitignore and working files | Prevent secrets from being included accidentally |
| Task scope | Define the permitted area of change in advance |
Baseline sequence
- Check the path to the current directory.
- Run
git statusand understand everymodified,deleted, oruntrackedfile. - Create a separate branch for the new task if the project process allows it.
- Check
.gitignorerules and the actual contents of the workspace. - Write down the allowed and forbidden parts of the task.
- Only then start Claude Code and provide it with context.
pwd
git status
git switch -c fix/refund-inbox-order
git check-ignore -v .envWhat to do with an unclear diff
Do not silently mix existing local changes with a new task. First investigate the specific file or range, determine where the changes came from, and only then decide whether to finish, commit, temporarily set aside, or discard them.
A separate branch does not automatically fix a conceptual mistake. It only makes the experiment boundary visible and lets you return to the previous state.
git diff src/support/refund/RefundInboxService.java
git diff
git statusA short scope before starting Claude
- Name a specific goal instead of saying “improve the module.”
- Specify the allowed directories or files.
- List areas that cannot be changed without a separate decision.
- Define in advance how you will verify the result.
Task: check the order of refund requests in the inbox.
Allowed changes: src/support/refund/** and related tests.
Forbidden changes: API contracts, database migrations, .env* files, and environment configuration.Control after Claude’s work
- Review the complete
git diffand the number of changed files. - Compare the actual change area with the initial scope.
- Run relevant tests, lint, or build checks.
- Check the key scenario manually if automated checks are insufficient.
- If the iteration failed, first determine exactly what should be kept or rolled back.
git diff
git restore src/support/refund/RefundInboxService.java
git statusCanonical lesson source · JavaRush
Open JavaRush material