edit-loop
Model bir turn içinde aynı dosyayı beş kere düzenlediğinde bunu modele söyleyen bir Claude Code Mod'u. Böylece model tekrar denemek yerine kök sebebi yeniden okur. Hiçbir şey durdurulmaz.
Ne yapar
Mod Edit, Write ve NotebookEdit tool'larını hook'lar. Başarılı her çağrı, kendi dosyası için bir edit sayılır. Reddedilen ya da başarısız çağrı sayılmaz.
Sayaç loop ve dosya başına tutulur: main loop ve her subagent ayrı sayar. Yeni bir turn her sayacı sıfırlar.
Bir turn'de bir dosyanın üçüncü edit'i yalnız sizi uyarır, sarı renkte:
edit-loop: 3rd edit of hooks/a.ts in this turnModel bu sayıda hiçbir şey okumaz.
Bir turn'de bir dosyanın beşinci edit'i, sonucundan sonra şu notu alır:
edit-loop: this turn edited hooks/a.ts 5 times. Stop editing it, re-read the code path and state the root cause before the next edit.Dosya session'ın başladığı dizinin içindeyse path ona göre yazılır. O dizin session başlangıcında bir kere okunur, çünkü bir Bash
cdsession'ın kendi dizinini kaydırır. Not dosya ve turn başına bir kere gelir; altıncı ve sonraki edit'ler not almaz.Aynı anda transcript'e bir satır yazılır, böylece modele ne söylendiğini görürsünüz. Bu satır talimat cümlesi olmadan yalnız bulguyu taşır ve kırmızı çizilir:
edit-loop: 5th edit of hooks/a.ts in this turnNot ve satır ayrı iki kanaldır: model satırı hiç okumaz, siz notu hiç okumazsınız.
sidebar açıkken iki satır da oraya gider, stream'in içinde kayıtlar olarak; transcript temiz kalır. Bir kayıt, yenileri onu pane'in dışına itene kadar durur. Sidebar kapalıyken ya da o mod kurulu değilken yukarıdaki transcript satırı yazılır.
Canlı testte model bir turn'de bir dosyayı altı kere düzenledi. Beşinci edit'ten sonra notu okudu, dosyayı yeniden okudu, edit'lerin neden kasıtlı olduğunu söyledi ve notu kelimesi kelimesine aktardı. Diğer beş edit not almadı.
Komut
/edit-loop on ya da off
/edit-loop on | off varsayılan on
Kurulum
claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install edit-loop@kilimcininkoroglu-mods
Function hook'lar early access. Flag olmadan hiçbir şey yüklenmez. Flag'i kalıcı yapmak için ~/.claude/settings.json dosyasına ekleyin:
{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }
Kurulumdan sonra
- Claude Code'u yeniden başlatın.
Nereye uzanır
Claude Code 2.1.278 üzerinde claude plugin validate ile doğrulandı:
❯ ./register.ts hooks: session.start, command.run{command=edit-loop}, turn.start, tool.call{tool=Edit}, tool.call{tool=Write}, tool.call{tool=NotebookEdit}
❯ ./register.ts calls: $.command.register, $.session.cwd, $.sidebar.set (via toPerson), $.store.get, $.store.set (via runCommand), $.ui.log (via toPerson)
Reach L0, hatırlar.
1. Okur: her Edit, Write ve NotebookEdit çağrısının dosya path'ini; session'ın dizinini
2. Çalıştırır: hiçbir şey
3. Gönderir: bir turn'de bir dosyanın beşinci edit'inden sonra modele bir not, üçüncü ve beşincide transcript'e bir satır; makineden hiçbir şey çıkmaz
4. Saklar: $.store içinde on/off ayarını; sayaçlar bir turn boyunca bellekte yaşar
5. Düşman girdi: path yalnız karşılaştırılır ve notta yazılır, hiç açılmaz
Sınırlar
- Bash üzerinden yapılan bir edit (
sed -i, bir heredoc, bir script) sayılmaz. - Bir dosyanın beş edit'i kasıtlı olabilir, örneğin parça parça yazılan uzun bir dosya. Not bir sebep ister, hiçbir şeyi durdurmaz.
- Sayaç, tool çağrısının adlandırdığı path'i izler, yani iki farklı yazımla (bir link,
..) gelen tek dosya iki kere sayılır.
Geliştirme
make install # eslint, typescript-eslint, typescript
make lint # complexity limiti 10, üstünde build'i düşürür
make typecheck # /plugin-types ile üretilen .claude/types/ gerekir
make validate
make test # claude plugin test
edit-loop
A Claude Code Mod that tells the model when it has edited the same file five times in one turn, so it re-reads the root cause instead of trying again. Nothing is stopped.
What it does
The mod hooks the Edit, Write and NotebookEdit tools. Each successful call counts one edit of its file. A denied or failed call is not counted.
The count is kept per loop and file: the main loop and each subagent count apart. A new turn starts every count at zero.
The third edit of one file in a turn warns you alone, in yellow:
edit-loop: 3rd edit of hooks/a.ts in this turnThe model reads nothing at this count.
The fifth edit of one file in a turn gets this note after its result:
edit-loop: this turn edited hooks/a.ts 5 times. Stop editing it, re-read the code path and state the root cause before the next edit.The path is relative to the directory the session started in when the file is inside it. That directory is read once at the session's start, because a Bash
cdmoves the session's own directory. The note comes once per file and turn; the sixth and later edits get none.The same moment writes one line to the transcript, so you see what the model was told. The line holds the finding alone, without the instruction, and it is drawn red:
edit-loop: 5th edit of hooks/a.ts in this turnThe note and the line are separate channels: the model never reads the line, and you never read the note.
While the sidebar is open, both lines go there instead, as entries in its stream, and the transcript stays clean. An entry stays until newer ones push it off the pane. With the sidebar closed, or without that mod installed, the transcript line is written as above.
In the live check the model edited one file six times in one turn. It read the note after the fifth edit, re-read the file, stated why the edits were intended, and quoted the note word for word. The other five edits had no note.
Command
/edit-loop on or off
/edit-loop on | off on by default
Install
claude plugin marketplace add KilimcininKorOglu/claude-code-mods
claude plugin install edit-loop@kilimcininkoroglu-mods
Function hooks are early access. Nothing loads without the flag. To keep it on, add this to ~/.claude/settings.json:
{ "env": { "CLAUDE_CODE_ENABLE_FUNCTION_HOOKS": "1" } }
After installing
- Restart Claude Code.
What it can reach
Validated with claude plugin validate on Claude Code 2.1.278:
❯ ./register.ts hooks: session.start, command.run{command=edit-loop}, turn.start, tool.call{tool=Edit}, tool.call{tool=Write}, tool.call{tool=NotebookEdit}
❯ ./register.ts calls: $.command.register, $.session.cwd, $.sidebar.set (via toPerson), $.store.get, $.store.set (via runCommand), $.ui.log (via toPerson)
Reach L0, remembers.
1. Reads: the file path of each Edit, Write and NotebookEdit call; the session's directory
2. Runs: nothing
3. Sends: a note to the model after the fifth edit of one file in a turn, and one line to the transcript at the third and the fifth; nothing leaves the machine
4. Persists: in $.store, the on/off setting; the counts live in memory for one turn
5. Hostile input: the path is only compared and printed in the note, never opened
Limits
- An edit through Bash (
sed -i, a heredoc, a script) is not counted. - Five edits of one file can be intended, for example a long file written in parts. The note asks for a reason, it stops nothing.
- The count follows the path as the tool call names it, so one file under two spellings (a link,
..) counts twice.
Development
make install # eslint, typescript-eslint, typescript
make lint # complexity limit 10, fails the build above it
make typecheck # needs .claude/types/ from /plugin-types
make validate
make test # claude plugin test