AI Coding Tip 001 - Commit Before Prompt
A safety-first workflow for AI-assisted coding

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
Search for a command to run...
A safety-first workflow for AI-assisted coding

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.
No comments yet. Be the first to comment.
Approve the logic once, then let it run the same way forever.

Different stages need different brains.

One Second Brain doesn't scale past one skull.

Style errors double when nobody enforces them.

Know who speaks before the skill runs TL;DR: Always define a clear role at the top of every skill file so you know whose perspective drives the execution. Common Mistake ❌ You write a skill full of

A safety-first workflow for AI-assisted coding
TL;DR: Commit your code before asking an AI Assistant to change it.
Developers ask AI assistant to "refactor this function" or "add error handling" while they have uncommitted changes from their previous work session.
When the AI makes its changes, the git diff shows everything mixed together—their manual edits plus the AI's modifications.
If something breaks, they can't easily separate what they did from what the AI did and make a safe revert.
You mix your previous code changes with AI-generated code.
You lose track of what you changed.
You struggle to revert broken suggestions.
Finish your manual task.
Run your tests to ensure everything passes.
Commit your work with a clear message like "feat: manual implementation of X".
You don't need to push your changes.
Send your prompt to the AI assistant.
Review the changes using your IDE's diff tool.
Accept or revert: Keep the changes if they look good, or run git reset --hard HEAD to instantly revert
Run the tests again to verify AI changes didn't break anything.
Commit AI changes separately with a message like refactor: AI-assisted improvement of X.
Clear Diffing: You see the AI's "suggestions" in isolation.
Easy Revert: You can undo a bad AI hallucination instantly.
Context Control: You ensure the AI is working on your latest, stable logic.
Tests are always green: You are not breaking existing functionality.
When you ask an AI to change your code, it might produce unexpected results.
It might delete a crucial logic gate or change a variable name across several files.
If you have uncommitted changes, you can't easily see what the AI did versus what you did manually.
When you commit first, you create a safety net.
You can use git diff to see exactly what the AI modified.
If the AI breaks your logic, you can revert to your clean state with one command.
You work in very small increments.
Some assistants are not very good at undoing their changes.
+bash
.git status # Check for uncommitted changes
.git add . # Stage all changes
.git commit -m "msg" # Commit with message
.git diff # See AI's changes
.git reset --hard HEAD # Revert AI changes
.git log --oneline # View commit history
+
This is only necessary if you work in write mode and your assistant is allowed to change the code.
[X] Semi-Automatic
You can enforce the rules of your assistant to check the repository status before making changes.
If your code is not under a source control system, you need to make this manually.
[X] Beginner
Use TCR
Use Vibe Test Driven Development
Break Large Refactorings into smaller prompts
Git Bisect for AI Changes**: Using git bisect to identify which AI-assisted commit introduced a defect
Reverting Hallucinations
Treating AI as a pair programmer requires the same safety practices you'd use with a human collaborator: version control, code review, and testing.
When you commit before making a prompt, you create clear checkpoints that make AI-assisted development safer and more productive.
This simple habit transforms AI from a risky black box into a powerful tool you can experiment with confidently, knowing you can always return to a working state.
Commit early, commit often, and don't let AI touch uncommitted code.
GIT is an industry standard, but you can apply this technique to any other version control software.
This article is part of the AI Coding Tip Series.