Agent Skills in Claude Code and Visual Studio Code: Setup, Benefits, Risks, and a Step-by-Step Example
AI coding assistants can change a project much faster than most beginners can review it.
A single request may update several files, create a new configuration file, install a dependency, rename a function, and modify documentation. Even when the result appears to work, some of those changes may be unnecessary or unrelated to the task.
Git gives you a way to slow the process down.
It can show which files changed, display the exact lines that were added or removed, separate staged and unstaged edits, and restore selected files when the result is not worth keeping.
The goal of this guide is not to memorize every recovery command. It is to build a repeatable review process that keeps AI-generated changes understandable.
Version note: Git commands used in this guide are widely supported, but exact output and editor integration may vary. Before publication, compare command behavior with the current official Git documentation for the Git version used in your tutorial environment.
By the end of this guide, you should be able to:
git diff;git diff --staged;This article assumes that you already understand:
git status, git add, and git commit.The safest time to review an AI change is before the AI makes it.
That may sound strange, but review becomes much easier when the repository begins in a clean, known state.
Open the project:
cd ~/projects/vibe-coding-practiceCheck the current status:
git statusThe ideal result is a message indicating that the working tree is clean.
That means:
Review recent commits:
git log --oneline -5You should recognize the latest commit as a valid project state.
If the working tree is not clean, stop before starting the AI task.
Run:
git diffThen decide whether the existing work should be:
Do not mix unknown existing edits with a new AI-generated change.
Before using GitHub Copilot or Claude Code, write down the expected scope.
For example:
Task:
Add an “AI Review Checklist” section to README.md.
Allowed files:
- README.md
Not allowed:
- No new files
- No dependency changes
- No edits to JavaScript files
Verification:
- Review the Markdown output
- Confirm that only README.md changedThis gives you a review baseline.
After the AI finishes, you can compare the result with the original task.
Without a defined scope, almost any change can look reasonable.
With a defined scope, unrelated changes become easier to identify.
git status as the First ReviewAfter the AI completes its work, do not rely only on its summary.
Run:
git statusThis command shows the project state at a high level.
You may see files listed as:
For example:
Changes not staged for commit:
modified: README.md
modified: package.json
Untracked files:
review-notes.txtIf the task was limited to README.md, the other two files require investigation.
Do not stage everything simply because the AI said the task was complete.
git statusReview the file list and ask:
git status tells you where to look next.
git diffRun:
git diffThis displays the differences between the working directory and the staged version.
If nothing is staged, it usually shows all tracked file edits since the last commit.
You may see output similar to:
-Old line
+New lineA line beginning with - was removed.
A line beginning with + was added.
The surrounding lines provide context.
When several files changed, inspect them individually:
git diff README.mdThen:
git diff package.jsonThis is easier than reviewing a large combined diff.
For each file, ask:
If the answer is no, do not commit yet.
git diff does not always display untracked file contents because Git is not yet tracking them.
List the directory:
ls -laOpen the new file in VS Code or print it in the terminal:
cat review-notes.txtBefore adding an untracked file, decide whether it belongs in the repository.
Common unwanted untracked files include:
Never add a file simply because the AI created it.
Before staging anything, scan the changed files for sensitive information.
Look for:
A generated .env file deserves special attention.
For example:
.envDo not commit it automatically.
Check whether .gitignore excludes it:
cat .gitignoreEven when a secret file is ignored, confirm that no credential was copied into source code, documentation, or terminal logs.
If a real secret was exposed, removing the line is not always enough. The credential may need to be rotated.
A code change can be valid and still be wrong for the task.
Suppose you asked the AI to add input validation.
The AI may also:
Some of those changes may be reasonable in isolation, but they increase review cost and risk.
A useful review question is:
What is the smallest change that satisfies the requirement?
If the AI result is much larger than that, consider editing it down or asking for a more focused attempt.
A visually reasonable diff does not prove that the change works.
Use the project’s normal verification method.
For a simple JavaScript file:
node copilot-practice.jsFor a project with tests:
npm testFor a project with a development server:
npm run devOnly run commands you understand and that belong to the project.
Do not approve a generated command merely because the AI recommends it.
Check:
Testing gives you evidence. The AI’s explanation does not.
After reviewing the changes, stage specific files.
For example:
git add README.mdAvoid:
git add .until every changed and untracked file has been reviewed.
Run:
git statusYou should now see README.md under staged changes.
Other files may remain unstaged.
This is useful when the AI produced one good change and one unwanted change.
Run:
git diff --stagedThis shows exactly what will enter the next commit.
That is your final pre-commit review.
Ask:
A clean staged diff should tell one clear story.
Suppose you staged package.json accidentally.
Run:
git restore --staged package.jsonThis removes the file from the staging area.
It does not delete the file’s working-directory changes.
Check:
git statusThe file should now appear as modified but unstaged.
This distinction matters:
Unstage = keep the edits, remove them from the next commit
Restore = discard the edits and return to a previous versionDo not confuse the two actions.
Suppose Claude Code changed package.json, but the task did not require dependency changes.
Review the file first:
git diff package.jsonIf you are certain the change should be discarded, run:
git restore package.jsonThis restores the working file to the staged or last committed version, depending on the current state.
For a normal unstaged change, it usually returns the file to the last committed version.
The uncommitted edits are lost.
Confirm the result:
git statusThen inspect the remaining changes:
git diffUse file-level restore only after confirming that the file contains no manual work you need.
You may restore multiple named files:
git restore package.json package-lock.jsonThis is safer than restoring the entire project because the target is explicit.
Review each file before doing so.
Package files often change together, so both may need to be restored when an unwanted dependency was added.
git restore does not remove untracked files because Git has no committed version to restore.
Suppose the AI created:
debug-output.txtOpen and inspect it first.
If it is truly unnecessary, remove it using the file manager or a direct command:
rm debug-output.txtThe rm command deletes the file.
There is no Git recovery for an untracked file that was never committed.
Check the filename and location carefully before running it.
Avoid broad commands that delete many files until you fully understand their scope.
Git can restore all tracked files in the current directory:
git restore .The period refers to the current directory.
This discards all unstaged edits to tracked files under that directory.
Use it only when:
Before running it:
pwd
git status
git diffThen pause and confirm that every listed edit can be lost.
For beginners, restoring individual files is usually safer.
Git commands are not the only review option.
VS Code’s Source Control view can display:
Select a changed file to compare the old and new versions side by side.
This can be easier for large edits.
However, the same safety rules apply.
Before using a graphical discard button:
A friendly interface does not make a destructive action safer.
When the staged diff is correct, create a commit:
git commit -m "Add AI review checklist to README"Then check:
git status
git log --oneline -3The commit should appear at the top of the history.
The working tree may still contain unstaged unwanted changes.
If so, review and restore them separately.
A commit does not automatically clean every file. It records only the staged changes.
git revertSometimes an AI-generated change is committed and later found to be wrong.
If the commit has already been shared or pushed, git revert is often a safer beginner option than rewriting history.
First, identify the commit:
git log --onelineYou may see:
f3a91c2 Add AI review checklist to README
c21f8a0 Document Claude Code setupTo reverse the first commit while preserving history:
git revert f3a91c2Git creates a new commit that applies the opposite change.
This produces a history like:
A ── B ── C ── DWhere:
C: Add AI review checklist
D: Revert "Add AI review checklist"The original commit remains visible.
This is valuable in shared repositories because the history clearly shows what happened.
Run:
git status
git log --oneline -5Then inspect the affected files.
If the revert created a conflict, stop and review the conflicting sections instead of repeatedly rerunning the command.
Git includes commands that can move branch history or discard commits.
Some tutorials recommend commands such as:
git reset --hardThis command can permanently discard local changes and move history.
It is not appropriate as a casual beginner recovery tool.
Do not use history-rewriting commands unless you understand:
For this beginner workflow, prefer:
git restore for unwanted uncommitted file changes;git restore --staged for accidental staging;git revert for reversing a committed change while preserving history.These commands make the intent clearer.
Suppose Claude Code was asked to add input validation and changed:
app.js
app.test.js
package.json
README.mdUse this process.
git statusgit diff app.js
git diff app.test.js
git diff package.json
git diff README.mdFor example:
app.js Required implementation
app.test.js Required verification
package.json Unexpected dependency
README.md Useful but unrelatedRestore the unwanted dependency edit:
git restore package.jsonDecide whether the README update belongs in a separate commit.
Stage the implementation and test:
git add app.js app.test.jsReview:
git diff --stagedCommit:
git commit -m "Validate empty task titles"Then stage the documentation separately if it is still useful:
git add README.md
git diff --staged
git commit -m "Document task validation behavior"This produces a clearer history than combining everything into one commit.
AI-generated changes often expand beyond the request in predictable ways.
Watch for:
Not every extra change is wrong.
The question is whether it is necessary, understood, and appropriate for the current commit.
When unsure, keep the requested change small and leave broader refactoring for a separate task.
You may ask the coding assistant:
Summarize every changed file, explain why each change was necessary, and identify any new dependencies. Do not modify the project.This can help organize the review.
However, compare the answer with:
git status
git diffThe AI may:
Git shows the repository evidence.
The AI provides commentary.
Do not confuse the two.
Before accepting AI-generated changes, ask:
You do not need to be an expert in every language to ask these questions.
They help you review intent, scope, and evidence.
Use this sequence after every meaningful AI task.
git statusgit diffls -lanpm testUse the command appropriate to the project.
git restore path/to/unwanted-filegit add path/to/verified-filegit diff --stagedgit commit -m "Describe the verified change"git status
git log --oneline -3This workflow turns Git into a review boundary around the AI assistant.
Before moving to the final article in this series, confirm that you can explain and use:
git status to list changed files;git diff to review unstaged tracked changes;git diff --staged to review the next commit;git restore --staged filename to unstage without deleting edits;git restore filename to discard an unwanted uncommitted tracked-file change;git revert commit-id to reverse a committed change with a new commit;Also remember:
A clean AI response is not the same as a clean Git diff.
If you want to go beyond basic Git diffs and develop a more systematic approach to reviewing AI-generated code, my book, Practical Code Review in the Age of AI: Review Like a Senior, expands on many of the ideas introduced in this guide. It covers practical review habits, risk-based thinking, maintainability, testing, security, and the judgment required to evaluate code produced by AI coding assistants. You can find the book on Amazon: Practical Code Review in the Age of AI: Review Like a Senior.
Git gives you a controlled way to evaluate AI-generated changes.
git status shows which files changed. git diff shows the exact edits. The staging area lets you select only the files you trust. git restore can discard unwanted uncommitted changes, while git revert can reverse a committed change without hiding the history.
The safest process is to start from a known checkpoint, define the expected scope, review every changed file, test the result, and commit only the verified portion.
The next and final article in this setup series will combine everything into one complete workflow. We will move from opening a WSL project and checking Git status to choosing an AI tool, reviewing the result, testing it, committing it, and pushing the verified change to GitHub.
git restore and git revert?git restore is commonly used to discard uncommitted file changes.
git revert creates a new commit that reverses an earlier commit while preserving the original history.
Usually not.
If a file was never added or committed, Git has no stored version to restore. Inspect untracked files carefully before deleting them.
git reset --hard to undo AI changes?Not as a routine beginner workflow.
It can discard local work and move history. Prefer file-level git restore, unstaging with git restore --staged, or history-preserving git revert unless you fully understand the consequences.
Comments
Post a Comment