Quick answer: AI agents duplicating work is a coordination gap, not a model flaw. Two agents start on related tasks, neither can see what the other is building, and both ship an implementation. You stop it with five checks before any code gets written: one owner per task, a board search, a repo and open-PR search, linked related tasks, and a “check before you build” step in every agent’s instructions.
A reader asked us a sharp question after a post about running several coding agents at once. Paraphrased: when two agents pick up related tasks, how does anyone find the existing implementation before the second agent starts a parallel one? In most setups the answer is “the human remembers,” which is the job you were trying to hand off.
This guide covers how the duplication happens, the five checks that prevent it (cheapest first), which of them Sharkly handles for you today, and which ones you still set up yourself. It ends with an instruction block you can paste into any agent.
How AI agents end up duplicating work
Duplicate work happens when two agents solve overlapping problems from separate task descriptions, with no step that makes either one look at the other’s work. Each agent sees its own task, its own worktree and the code on the default branch. Work that lives in an unmerged branch is invisible to it.
Here is a realistic example. Task API-212 says “Add retry with backoff to the payments client” and goes to Claude Code. Task API-215 says “Fix flaky webhook delivery” and goes to Codex an hour later. Codex decides the webhook fix needs retries, finds no retry helper on main, and writes utils/retry.ts. Claude Code is halfway through lib/backoff.ts on its own branch. Both pull requests pass CI. Your reviewer now owns two retry helpers with different jitter rules.
Neither agent did anything wrong. The webhook agent searched the code it could see. The missing piece was a look at work in flight: open tasks, open branches and open pull requests.
Anthropic hit the same failure inside its own multi-agent research system. Its engineering write-up says that “without detailed task descriptions, agents duplicate work, leave gaps, or fail to find necessary information”, with three subagents researching overlapping supply-chain questions. The fix there was better task division by the coordinator. With coding agents, you are usually the coordinator.

Note what worktree isolation does and does not solve. Separate worktrees stop two agents from overwriting each other’s files, which we cover in how Sharkly runs agents in parallel without merge conflicts. They do nothing about two agents writing the same feature in two places. Isolation makes duplicates quieter, because there is no merge conflict to warn you.
Five checks to stop parallel coding agents from colliding
Run these in order. The first two cost seconds; the last one costs a paragraph of instructions, once.
- One owner per task. Every task has exactly one agent executing it.
- Search the board. Before starting, the agent lists open tasks in the same area and reads their titles.
- Search the repo and work in flight.
git grepon the default branch, then open branches and pull requests. - Link related tasks. When two tasks touch the same code, record that on both tasks.
- Put “check before you build” in the agent instructions. So checks 2 to 4 happen on every run without you asking.
Why does one owner per task matter?
Two agents on the same task is the most direct form of duplicate work. It happens when someone reassigns a task without stopping the first run, or when a second chat on the task starts a fresh implementation. One owner means one execution slot per task, and a handoff is a reassignment, not an addition.
How does an agent search the board before starting?
Give the agent a command that returns open tasks with owners, scoped to the same Project or label. Titles are enough to catch “retry” in API-212 while working on API-215. The agent reads the list, then reads the description of any task that looks close.
# Open tasks in the same Project, with owner, filtered by keyword
sharkly task list --project "$PROJECT_ID" --status "In Progress" --output json \
| jq -r '.[] | select(.title | test("retry|backoff|webhook"; "i")) | "\(.identifier) \(.title)"'
How do you find an implementation that is not merged yet?
Search three places, in this order: the default branch, remote branches and open pull requests. The git grep call catches merged code. Remote branch names catch work that has no PR yet. The GitHub CLI’s gh pr list --search catches open PRs by keyword.
git fetch --prune
git grep -n -i -E "retry|backoff" -- src/
git branch -r | grep -i -E "retry|backoff|API-2"
gh pr list --state open --search "retry in:title,body"
When should you link related tasks?
Link them the moment either side finds the overlap. A link turns a private discovery into something the next agent and the reviewer can see. Write which task owns the shared code, so the other one imports it instead of rebuilding it.
What Sharkly covers and what you add
Sharkly gives you the structure for checks 1, 3 and 4, and a place to put check 5. It does not detect duplicates for you. Here is each claim, checked against the Sharkly docs on 2026-11-30.
| Check | What Sharkly does today | What you add |
|---|---|---|
| One owner per task | A task’s execution slot (Agent or Crew) is single-select | Reassign instead of adding a second chat that rebuilds |
| Search the board | Agents in a run can call the sharkly CLI; task list filters by Project, label, status and assignee |
Keyword matching: the CLI has no title search flag, so pipe JSON through jq |
| Repo and PR search | Task chat branches are named after the task ID; the GitHub integration links a PR to a task when the ID is in the branch, title or body | Running git grep and gh pr list in the agent’s instructions |
| Link related tasks | Linked items: blocks, is blocked by, duplicates, relates to; a Duplicate status that records the original | Deciding which task owns the shared code |
| Check-before-build step | Agent instructions are supplied to every run | Writing the step (block below) |

Two limits matter. First, there is no automatic duplicate detection: Sharkly does not compare a new task against open ones, and it does not compare code across branches. Second, a relation records a fact without enforcing it. The docs say relations “do not merge tasks, change status, or start an Automation by themselves,” and merging a linked PR does not change task status either.
You can close part of that gap yourself. An Automation with a task-status-change trigger can start a checker agent whenever a task moves to Todo. That agent runs the board and PR search, then links or comments. It is a workaround you configure, not a built-in feature.
If you already run Claude Code and Codex side by side, the guide to running both on one codebase covers the repo-side setup this table assumes.
A check-before-you-build block for agent instructions
Paste this into the instructions of every agent that writes code. In Sharkly, that is the Agent’s instructions field, which travels with every run. In a plain Claude Code or Codex setup, put it in AGENTS.md or CLAUDE.md at the repo root.
## Before you write code: check for existing work
1. List open tasks in this Project:
sharkly task list --project <PROJECT_ID> --status "In Progress" --output json
Read the title of every task. Open the description of any task that touches
the same module, API or helper you are about to build.
2. Search merged code: git grep -n -i "<2-3 keywords from your task>"
3. Search work in flight:
git fetch --prune && git branch -r | grep -i "<keyword>"
gh pr list --state open --search "<keyword> in:title,body"
4. If you find overlapping work:
- Do not write a second implementation.
- Link the tasks: sharkly task edit <THIS_TASK> --link relates_to:<OTHER_TASK>
- Comment on this task: what you found, where, and who owns it.
- Ask whether to reuse it, wait for it, or proceed. Then stop.
5. If you find nothing, say so in your first comment and list what you searched.

Step 5 earns its place. A run that writes “searched tasks, git grep and open PRs for retry and backoff, found nothing” gives the reviewer proof the check ran. A run that says nothing leaves the reviewer guessing. For more on what a reviewer needs from a run, see designing review for parallel agents.
Other ways teams handle it
Some teams skip the board search and rely on a lead agent that splits the work up front. That is the Crew pattern: a leader assigns sub-work, so overlap gets caught at planning time. It works when one person or agent sees every task, as in mixed-model Crews with an Opus reviewer. It breaks down when tasks arrive from different people over days.
Others pin shared helpers in AGENTS.md (“retries live in lib/backoff.ts, never write another”). That prevents repeats of a known duplicate, not the first one. Use it after you have caught one.
For a wider view of the layer that sits above individual agents, read coding agent management: the layer above Claude Code and Codex.
Conclusion
Duplicate implementations come from agents that cannot see work in flight. One owner per task, a board search, a repo and PR search, linked tasks and a standing instruction close most of that gap. Sharkly supplies the single owner, the CLI, PR-to-task links and task relations; the search step and its keywords are yours to write.
Your next step: paste the block above into one agent’s instructions today, then read its first comment on the next task. Sharkly is free to start at sharkly.ai.
FAQ
Why do AI agents duplicate work?
Each agent sees its own task and the merged code. Work in unmerged branches and other tasks is invisible unless the agent is told to look. Two related tasks plus no pre-start search produces two implementations.
Does Sharkly detect duplicate tasks automatically?
No. Sharkly has no automatic duplicate detection for tasks or code. It gives you task relations, a Duplicate status that records the original, PR-to-task links and a CLI agents can use to search the board themselves.
Do separate worktrees prevent duplicate work?
No. Worktrees stop agents from overwriting each other’s files. Two agents can still write the same feature in two different files, and isolation means no merge conflict warns you.
What is the cheapest check to add first?
One owner per task, then a board search in the agent’s instructions. Both take minutes to set up and catch the most common overlap: two tasks that name the same module.
Should the agent stop or continue when it finds related work?
Stop and ask. Link the tasks, comment with what it found, and let a person decide between reuse, wait and proceed. Guessing is how a second helper gets written.
How do I link a pull request to a Sharkly task?
Put the task ID in the branch name, PR title or PR body after connecting the GitHub integration. Merging the PR does not change the task’s status.



