AIToday
Large Language ModelsAI Coding AssistantsZenn AI/MLPublished: Oct 8, 2026, 10:00 JST

Two Claude Code sessions duplicate T-408 twice in one file

Two Claude Code sessions duplicate T-408 twice in one file

3 Key Points

  1. What happened

    A developer ran one Claude Code session auto-continuing long work and another assigning tasks; within about an hour both added separate problems to the same file as T-408, spotted only when another session ran grep -n "T-408" and got two rows.

  2. Why it matters

    Both sessions were writing to a shared file without a step to check for duplicates after writing, so a later assigner reused a number another session had already taken, and the fix involved reassigning the later writer to T-410 and editing five more files.

  3. What to watch

    The article's suggested fix hinges on the assigner querying the current maximum number right before writing and checking for duplicates right after, but even that has a gap because the other session can write between the read and the write; the commands grep -oE '^- \[.\] \*\*T-[0-9]+' tasks.md | grep -oE '[0-9]+$' | sort -n | tail -1 and the uniq -d check are the ones to use.

WHO IT HITSDevelopers and teams that let AI coding assistants like Claude Code write tasks into shared files need a read-before-write and duplicate-check step, because the article's experience shows parallel sessions can silently reuse the same task number and force edits across code comments, tests, and scripts.

Not sure about something? Ask the AI

Questions and answers are published on this page.

Summaries like this, in your inbox every morning.

Context & Analysis

The article describes a workflow where a developer keeps all tasks in a single file outside the code repository, using lines formatted like "- [ ] **T-408** content". Two Claude Code sessions ran at once: one auto-continuing a long job via a custom script, and one assigning work. The assigning session, according to the article, did not re-read the file immediately before writing; it relied on the last number it had seen earlier. Meanwhile the other session had already consumed that number, so within about an hour two different problems landed under T-408.

The repair was asymmetric. Because the earlier writer's T-408 had already reached the main branch's code and handoff notes, the later writer was the one changed, to T-410 (T-409 having been taken in the meantime). That later number also appeared in code comments, tests, and a screen-capture script, so five files beyond the task file needed edits. The article's recommended request to Claude Code is to fetch the number from the file by command right before writing, not from memory, and to verify immediately after writing that the number does not appear twice. The article also notes a residual race: the other session can write between the read and the write, so the post-write check remains necessary. A stronger prevention, it says, is to let only one session add tasks, or to pre-assign number ranges (for example, telling one side to start at 500), as long as both sessions follow that rule.

FAQ
How did the duplicate T-408 get detected?
It was found when a different session that started afterward ran grep -n "T-408" and saw two rows for the same task number.
What commands does the article recommend for taking the next number and checking duplicates?
For the next number, run grep -oE '^- \[.\] \*\*T-[0-9]+' tasks.md | grep -oE '[0-9]+$' | sort -n | tail -1; after writing, run the same head filter piped to grep -oE 'T-[0-9]+' | sort | uniq -d to find duplicated numbers.
What should a developer ask Claude Code after it adds a task?
Ask two questions: when the file was read to take that number, and whether other sessions are currently writing to the same file.

AI news that matters for your work, delivered every morning.

Pick your industry and the AI tools you use, and get news related to your work every day.

Free · 30 seconds with Google · unsubscribe anytimeWhat is AIToday? →

Ask AI

Ask AI anything about this article. The AI reads this article, earlier AIToday articles, and Wikipedia, and cites its sources. Q&As are published on this page for other readers too.

Questions and answers are published on this page.

Related Articles

Next articleAI cluster networking reading list targets GPU engineers