JavaRush/Courses/Claude Code SELF/Diff as a quality gate

Diff as a quality gate

Open

1. Diff is a gate, not a highlight

โ€” Okay, I get the three boxes, โ€” says Tommy. โ€” But where do I actually sort them with my hands? Where do I even look at this diff?

Alex opens the terminal.

โ€” A couple of days ago you already learned how to look at changes before committing them. Scroll through, nod โ€œlooks okay.โ€ Now the next level: not just scroll through, but examine each change on its merits. Same command:

/diff       # show all changes โ€” go through each chunk separately

โ€” Only now the eye does not skim, โ€” Alex continues. โ€” You yourself said it: in someone else's code, skimming is dangerous. You go through the diff slowly, and for each chunk ask one question โ€” is it about the task or โ€œwhile we're at itโ€? โ€” and sort it into those three boxes:

โœ“ target fix                                โ†’ that's what was requested
โœ— reformatted half the file โ€œwhile at itโ€    โ†’ not the task
โœ— touched a neighboring area outside scope   โ†’ not the task
? added an unsolicited animation (unexpected) โ†’ not ordered; in someone else's work โ€” not it

โ€” And here's the important part, how this works by hand, โ€” Alex pauses. โ€” /diff shows you everything, but it does not let you carve out one piece and leave the rest โ€” that's not what it was built for. This is an inspection window, not a surgical table. So the decision is not โ€œaccept this line, reject that one.โ€ The decision is bigger: if there's a tail in the diff, the whole run is crooked. You do not take it as a whole; you ask the agent to redo it narrowly, exactly on the boundary.

โ€” So I don't filter pieces one by one, โ€” Tommy thinks aloud. โ€” I look at the diff and see that the run has sprawled, โ€” and send the whole thing back. Then I set the task tighter, so there won't be any tail.

โ€” Exactly. Diff is a quality gate: you're the gatekeeper at it. Spot something extra โ€” the run does not pass, you turn it back and make it cleaner. You do not fix a crooked duplicate piece by piece; you don't let it through at all. And now it is no longer โ€œdiff showedโ€ โ€” the diff is asking you whether to let the run in or not. And you answer, not the agent.

Tommy says his piece out loud:

โ€” Before, diff showed me โ€œthis changed here.โ€ And now, from it, I decide: this run goes into the project or back for rework.

โ€” Exactly. And the more precisely you reformulate the task afterward, the cleaner the next diff will be โ€” and there will be nothing to turn away.

2. When it's easier to rewind the whole run

โ€” And if Sam messed up so broadly that cleaning each piece by hand is a pain? โ€” asks Tommy. โ€” It really happens that he overhauled half the file.

โ€” It happens. Then don't suffer, โ€” Alex shows. โ€” Don't fish out a hundred tiny pieces one by one. Rewind the whole run at once:

/rewind     # rewind the sprawling run entirely and start again more carefully

โ€” Your very first course button, remember? โ€” Alex adds. โ€” It's alive and useful, but now it's the session's close-range safety net โ€” remove one bad run. Not the only net, but the top one of several: underneath it is the git branch you studied recently.

Tommy nods. Once he thought this button would save him from anything. Now he sees its honest place.

3. Trust mode based on risk

โ€” Listen, can I make it so it doesn't even go into someone else's code in the first place? โ€” Tommy wants not to catch the tail every time, but to block it at the entry. โ€” I'm tired of cleaning up after it.

โ€” You can. Half the success is choosing the right mode in advance, โ€” Alex switches. โ€” Remember the โ€œtrust dialโ€ from last week? Before, you turned it by habit. Now โ€” by the cost of the mistake. And the first thing you do on someone else's code is NOT trust blindly.

โ€” Claude Code has 3 operating modes:

  • manual - The AI asks permission for any action with files on disk
  • acceptEdits - editing is allowed.
  • plan mode - nothing on disk can be changed at all. We only do planning.

You can switch them using the key combination โ€œShift+Tabโ€.

โ€” Let me explain each of them, โ€” Alex continues. โ€” manual means โ€œshow every file change and ask before touching anything.โ€ In commands it's also default: --permission-mode default. There is a faster mode, acceptEdits: the agent edits files in the project on its own and doesn't bother you. It's good in your own code, no problem. On someone else's code, it's an enemy: the agent will do a ton of stuff and you won't even see it. So in someone else's apartment โ€” manual, we see every step.

โ€” And the rule here is one, โ€” Alex adds, โ€” set the dial by risk, not by habit. Let safe things โ€” reading files, running tests โ€” go freely. Dangerous things โ€” edits in someone else's area โ€” keep strictly under control. And let the borderline stuff ask.

4. Point permissions rules in settings.json

โ€” And won't reading what the AI asks and answering every time get exhausting? โ€” Tommy looks for a way to simplify the work.โ€” The more questions it asks, the less carefully I read them.

โ€” It won't get exhausting; you can write the same thing once, โ€” Alex opens settings. โ€” So that you don't have to decide again at every step what to ask about and what to forbid, you can write all the rules in .claude/settings.json:

{
  "permissions": {
    "ask":  ["Edit(src/partner/**)"],
    "deny": ["Edit(legacy/**)"]
  }
}

โ€” Let me explain what's written here, โ€” Alex continues. โ€” Edit means โ€œthe agent edits the file,โ€ and in parentheses is where. src/partner/** is the whole src/partner folder with everything inside it, your work area for today; any edits there โ€” ask. And legacy/ is an old, long-frozen piece of the portal that must not be touched at all; put it in deny โ€” and edits there are forbidden completely, the agent will not even suggest them. It hits paths surgically, not โ€œallow everythingโ€ or โ€œforbid everything.โ€

Tommy looks at the two lines and, figuring it out on his own, builds the third basket:

โ€” So we can mark folders in advance? Dangerous things โ€” in deny. Borderline things โ€” in ask. And safe things I don't write anywhere โ€” they go through freely, like allow by default. Three baskets: forbid, ask, allow.

โ€” Exactly. Just keep in mind, โ€” Alex adds, โ€” this is still the dial plus a few rules for specific paths. A full permission system, where the project's whole policy is written out in advance like law, is a separate grown-up topic for later. And the syntax changes over time โ€” stick to the logic, not the brackets: forbid / ask / allow.

5. Why โ€œasking about everythingโ€ kills protection

Tommy has what seems to him like a brilliant idea:

โ€” Oh! Then I'll set ask on everything. Let it ask about every move. Maximum protection!

โ€” Stop, โ€” Alex cuts him off. โ€” That's the trap. It's called confirmation fatigue. If the agent pings you for every little thing โ€” opened a file? ask. read a line? ask โ€” after twenty minutes you'll start clicking โ€œyesโ€ without looking, on autopilot. And then confirmation will die as protection: it works only while you read it. And you'll stop reading because you've had enough.

Tommy tries it on himself โ€” and recognizes his own night habit of clicking โ€œyesโ€ to everything. Now he can see where it comes from: not from stupidity, but from fatigue.

โ€” So asking about everything is the same as asking about nothing, โ€” he says slowly. โ€” I'll just stop reading carefully.

โ€” Exactly. So do the opposite: leave โ€œaskโ€ only where you really need to think. Let safe stuff through freely, forbid dangerous stuff completely โ€” so there won't even be a question. Put only the borderline cases under question, where the cost of a mistake is high and a human must decide. Then you read every โ€œaskโ€ seriously, because there are few of them.

1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Runaway change โ€” roll it back completely ๐ŸŒ€
Runaway change โ€” roll it back completely ๐ŸŒ€
1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Frozen chunk โ€” do not touch ๐ŸงŠ
Frozen chunk โ€” do not touch ๐ŸงŠ
1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Don't Trust Blindly ๐ŸŽš๏ธ
Don't Trust Blindly ๐ŸŽš๏ธ
1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Gate on the diff ๐Ÿšฆ
Gate on the diff ๐Ÿšฆ
1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Remove the runaway attempt ๐ŸŒ€
Remove the runaway attempt ๐ŸŒ€
1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Permissions in settings.json ๐Ÿ”
Permissions in settings.json ๐Ÿ”
1
Task
Claude Code SELF,  15 level,  3 lecture
Locked
Do not ask about everything ๐Ÿ™…
Do not ask about everything ๐Ÿ™…
ะšะพะผะผะตะฝั‚ะฐั€ะธะธ
  • ะฟะพะฟัƒะปัั€ะฝั‹ะต
  • ะฝะพะฒั‹ะต
  • ัั‚ะฐั€ั‹ะต
ะ”ะปั ั‚ะพะณะพ, ั‡ั‚ะพะฑั‹ ะพัั‚ะฐะฒะธั‚ัŒ ะบะพะผะผะตะฝั‚ะฐั€ะธะน ะ’ั‹ ะดะพะปะถะฝั‹ sign in
This page has no comments yet