> ## Documentation Index
> Fetch the complete documentation index at: https://mux.coder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompting Tips

> Tips and tricks for getting the most out of your AI agents

## Persist lessons

When you notice agents making the same class of mistake repeatedly, ask them to persist the fix:

* **Global guidance**: update `AGENTS.md` (keep it short and general)
* **Local guidance**: add a comment near the relevant code when the lesson is scoped to one area

Two patterns that help:

* Put a size constraint on the change (for example: “change at most two sentences”).
* Ask for the general rule, not a one-off exception.

Codebases often have “watering hole” files that are touched in a wide range of changes (for example, API boundaries). If a lesson only matters in one spot, it’s usually better as a local comment than as global policy.

## Define the loop

Agents thrive on TDD and explicit “done means green” loops.

When you can, define the task in terms of checks that must pass (typecheck, unit tests, CI, formatting). In this repo, `scripts/wait_pr_checks.sh` is a good example of an explicit end condition.

## Aggressively prune context

Even with large-context models, we usually see better results when the active context stays relatively small (for example, under \~100k tokens).

A simple pattern is to compact and immediately continue:

```text theme={null}
/compact
<what you want next>
```

Mux will run compaction and then automatically send your follow-up message.

## Queue messages while the agent is working

When an agent is mid-stream you can still type and send a follow-up. The message gets queued and delivered automatically — the **dispatch mode** controls *when*:

| Mode                          | Shortcut     | Behavior                                                             |
| ----------------------------- | ------------ | -------------------------------------------------------------------- |
| **Send after step** (default) | `Enter`      | Your message is delivered as soon as the current tool call finishes. |
| **Send after turn**           | `Ctrl+Enter` | Your message is delivered after the agent's entire turn completes.   |

You can also pick the mode from the context menu on the send button.

**When to use each:**

* **After step** is useful when you want to course-correct early — the agent will see your message before it starts the next tool call.
* **After turn** is useful when you want to let the agent finish its current line of thought uninterrupted, then pivot.

## Keep code clean

Prompts that often lead to better long-term code:

**Elevate the fix to design level:**

* “We keep seeing this class of bug in component X. Fix this at a design level.”
* “There’s bug X. Provide a fix that solves the whole class of bugs.”

**Before compaction (end of a long session):**

* “How can the code/architecture be improved to make similar changes easier?”
* “What notes in `AGENTS.md` would make this change easier for future assistants?”

**After compaction (fresh context):**

* “DRY your work.”
* “Strive for net LoC reduction.”
* “Review in depth; simplify.”
