# Code that relies on lucky timing

Prompt · Architecture and hidden complexity · A06

Finds code that only works because things usually happen in the right order.

## Prompt

```text
Identify asynchronous operations whose correctness depends on events happening in a particular order without an explicit guarantee. Trace the scheduling, retries, cancellation, and conflicting writes; reproduce the highest-risk cases and propose the smallest enforceable contract.
```

**What it returns:** The assumed order, what can reorder it (retry, webhook, slow network), and a reproduction for the worst case.

**Skip it when:** Scripts that do one step at a time with nothing running side by side.

**Tools:** Repository; a way to run the code locally to reproduce the problem.

**Changes:** Adds a test that shows it

**Sessions:** Look first, then fix in a new session

## Skills

- [diagnosing-bugs](https://www.atlasscope.dev/skills/diagnosing-bugs): Diagnosis loop for hard bugs and performance regressions.

## Related

- [Updates that overwrite each other](https://www.atlasscope.dev/prompts/updates-that-overwrite-each-other): Finds updates that overwrite newer data because two things wrote at once.
- [Status hidden in a pile of flags](https://www.atlasscope.dev/prompts/status-hidden-in-a-pile-of-flags): Finds features whose real status is spread across a pile of yes/no flags, so combinations that should be impossible can happen.
- [When an outside service goes down](https://www.atlasscope.dev/prompts/when-an-outside-service-goes-down): Asks what happens to the app when Google, the AI Gateway or a service that sends it updates goes down.

Source: https://www.atlasscope.dev/prompts/code-that-relies-on-lucky-timing
