# Agent prompt recipes

Source: https://olef.dev/docs/engineers/prompts

Most developers rarely type all 359 `olef` commands by hand—you describe the outcome and let your coding agent drive Olef. Strong prompts name **the starting state**, **the evidence to collect**, and **the proof required before declaring done**.

## Fix a crash with before-and-after evidence

```text
The app crashes when I tap Checkout with an empty cart. Use Olef to
reproduce the crash, run `olef why` and inspect the stack trace and local
state, make the smallest fix, apply it with `olef app apply`, and prove
with a fresh run that tapping Checkout now shows the empty-cart message
with zero new error logs.
```

## Verify Room persistence & WorkManager sync

```text
Add a task offline in the app, kill and restart the app, and verify with
`olef storage` and `olef work` that:
1) the task exists in SQLite/Room after restart,
2) the sync WorkManager job is enqueued with the expected input data, and
3) after triggering `olef work run`, the row flips to `synced = 1`.
Report any unmet WorkManager constraints before changing code.
```

## Debug a visual or Compose layout issue

```text
Read my annotations from the live viewer with `olef pane annotations`.
For each note, inspect the mapped Compose source and recompositions
(`olef layout recompositions --why`), fix the root cause, apply the
change in place, and show me an updated annotated screenshot (`--annotate a11y`)
confirming the layout and tap targets are fixed.
```

## Hunt startup regressions, jank & memory leaks

```text
Measure baseline cold startup (`olef perf startup --mode cold --iterations 5`)
and scroll jank on the Feed screen (`olef perf frames`). Then open a Detail
screen and press Back three times and run `olef perf leaks`. If any
Activity, Fragment, or ViewModel is retained, trace the GC-root chain in
the code, fix it, and re-run `perf leaks` to confirm zero leaks.
```

## Automate a hybrid WebView checkout flow

```text
Navigate to the embedded WebView payment screen. Use `olef web` to dump
interactive DOM elements (including Shadow DOM/iframes), enter the test
coupon code, tap Apply, and confirm no native Android dialog is covering
the button and no uncaught JS errors appear in `olef web console` or `olef why`.
```

## Test notifications, App Links & process death

```text
Verify our deep link `https://example.com/order/99` using `olef app applinks`
and `olef app resolve-intent`, launch it with `olef app open-intent --expect-front`,
then inject process death with `olef fault inject process-death` and prove
the order screen restores its state cleanly. Clear all faults when done.
```

## Audit accessibility & scaffold test code

```text
Run `olef ui audit` and `olef ui audit --a11y` on the Profile and Settings
screens. Report interactive controls missing stable resource IDs or Compose
testTags and any accessibility issues. Add testTags where missing, then run
`olef ui gen` to scaffold a clean Kotlin Screen Object.
```

## Record, verify & heal a regression test

```text
Run the sign-in and create-project flow inside an Olef session, add an
explicit `olef record check` on the project dashboard, save it with
`olef record save create_project`, and run `olef test run tests/olef/create_project --repeat 3`.
If an existing test fails after my refactor, run `olef test heal` and show
me the proposed diff before editing the test.
```

## Run on a physical phone or share a private build (`ocloud`)

```text
Run our checkout regression suite on a physical Pixel via
`ocloud devices run ddp:tokay-36 -- olef test run tests/olef/checkout`
(confirm daily spend cap first). If it passes, push the debug APK to the
"Designers" tester group with `ocloud builds push --share Designers`.
```

For how Olef structures tool responses and error codes, see [The agent loop](https://olef.dev/docs/concepts/agent-loop) and [The output contract](https://olef.dev/docs/concepts/output-contract).
