# Record failed attempts so no AI repeats them

Canonical: [Record failed attempts so no AI repeats them](https://contextingo.com/guides/record-failed-attempts-ai-coding-agents)

Locale: en

Purpose: Save what an AI tried and why it failed as a record every teammate’s AI reads first, so Claude Code and Codex stop repeating the same dead end.

Content updated: 2026-10-26

Source revision: content.ts 2026-10-26

Maintenance owner: the Contextingo site owner

[Topic map](https://contextingo.com/llm/topics/guides.md) · [Complete scoped map](https://contextingo.com/sitemap.md)

An AI that does not know what was already tried will try it again: the same library, the same workaround, the same broken migration. In a chat that knowledge is gone when the chat ends. In Contextingo a failed attempt is its own kind of record, tied to the issue, that every teammate’s AI reads before it starts.

1. **Connect your AI to the project.** Run the setup command from Project → Connect in the repository folder. Claude Code and Codex are supported.

   ```
   npx contextingo init <code>
   ```
2. **Save the attempt when it fails.** When an approach does not work, the AI calls `context_upsert` with kind `failed_attempt`: what it tried, what happened, and why it failed, with the source (an error, a test run, a file). In Claude Code the hook reminds it at the end of a turn that changed things without saving anything.
3. **Tie it to the issue or branch.** Save it with the issue (and the branch when it only applies there). Records for an unmerged branch are left out of other branches, so a dead end on one experiment does not block another.
4. **Every AI reads it before it starts.** At the start of work the AI calls `context_get` for the issue and gets its requirements, decisions, findings and failed attempts. `context_search` finds an earlier attempt by word, for example the name of the library that did not work.
5. **Keep it correct when things change.** If a later version makes the approach work after all, archive the record with a reason, or replace it with `supersedes`. Every version stays in the history. An AI that doubts a record reports a problem instead of deleting it.

## Questions

### Why does Claude Code keep trying a fix that already failed?

Because the failure only lived in the conversation. After /clear, in a new session or on a teammate’s computer that part of the chat is gone, and a compaction can summarize it away. CLAUDE.md does not stop it either: Claude Code reads it as context, not as rules it must follow (Claude Code memory documentation, October 2026). A failed attempt saved as a record stays with the issue, and when the AI names the files it is about to edit, failed attempts on those files come first.

### Why not write failed attempts in the commit message or the issue?

A failed attempt often has no commit, and issue comments are not read by the next AI in a structured way. As a record it has a kind, a status and a source, and every connected AI gets it at the start of work on that issue.

### Does this slow the AI down?

Reading is one call at the start and then only the changes since its last sync token. Saving a failed attempt is one call.

### Who can confirm or remove a failed attempt?

An AI can save and update records, and confirm one it checked itself (it needs a source). A record a person confirmed can only be changed by a person; an AI can only report a problem with it.
