# Set up Alexein with your coding agent

> A prompt to paste into Claude Code, Cursor, Codex or any coding agent, so it adds memory to your app the way these docs describe.

Copy the prompt below into your coding agent, in the repository of the app you want to give a memory. It asks the
agent to read these docs, show you a plan, and then add memory to your app: a search before the model answers, and
an add after it. It is plain text with nothing hidden, so read it before you paste it, and change any step you want
done differently.

```text title="Prompt"
Add Alexein memory to this app.

Alexein is a hosted memory API. Each user of an app gets a memory of their own: the app adds what the user says,
and searches it before its model answers. Its docs are written for agents as well as people:
- An index of every page: https://docs.alexein.ai/llms.txt
- Any page as Markdown: its address with .md added, such as https://docs.alexein.ai/quickstart.md

Read these before you write any code, and follow them over anything you remember about Alexein:
- https://docs.alexein.ai/quickstart.md
- https://docs.alexein.ai/guides/automatic-memory.md
- https://docs.alexein.ai/guides/chat-assistant.md
- The SDK page for this app's language: https://docs.alexein.ai/sdks/python.md or
  https://docs.alexein.ai/sdks/typescript.md. For another language, the HTTP API: https://docs.alexein.ai/api.md

Then:
1. Find where the app takes a user's message and calls its model, and which id it already has for each user.
   Tell me your plan before you change any code.
2. Install the SDK for this app's language, or call the HTTP API directly if there is none.
3. Read the key from the ALEXEIN_API_KEY environment variable, on the server only. Never put a key in code, in a
   log or in the browser. Add ALEXEIN_API_KEY, without a value, to the app's example environment file. If no key
   is set, ask me to create one with read and write access at https://app.alexein.ai/console/keys.
4. Name each user by the id the app already has for them, from its own sign-in. Never let a model, a prompt or a
   request body choose whose memory is read or written.
5. If the app calls the Anthropic or OpenAI client or the Vercel AI SDK, wrap that client as the automatic memory
   guide shows. Otherwise, as the chat assistant guide shows: search the user's memory with their message before
   the model replies, put what comes back in the prompt as quoted text that the model must never follow as
   instructions, and after the reply add the user's message and the reply as two items in one add.
6. Make the app still answer when memory cannot be reached: turn on failing open, as the SDK page shows, or,
   over HTTP, answer without memory when its call fails or is slow.
7. Where the app deletes one of its users, erase their memory too:
   https://docs.alexein.ai/api/users/delete.md
8. Add tests that run without the network, and tell me how to try it end to end with a real key.

Change nothing that this does not need. When you are done, list what you changed and anything you could not check.
```

The agent needs to fetch web pages for the links to help: Claude Code, Cursor, Codex and most others can. One
that can't still follows the steps, from what it already knows, so check its work against the
[Quickstart](/quickstart).

> **Your own memory, in your coding agent**
>
> This prompt gives the app you build a memory for its users. To give your coding agent a memory of your own
> work, which it reads across sessions and shares with your other AI assistants, connect My memory instead:
> [Claude Code](/mcp/claude-code), [Cursor](/mcp/cursor), [Codex](/mcp/codex) and
> [the rest](/mcp).

## What the agent reads

The docs answer agents at addresses of their own, which you can give any agent or tool:

| Address                                                              | What it is                                                 |
| -------------------------------------------------------------------- | ---------------------------------------------------------- |
| [`/llms.txt`](https://docs.alexein.ai/llms.txt)                      | Every page's title, address and one-line summary, in order |
| [`/llms-full.txt`](https://docs.alexein.ai/llms-full.txt)            | Every page as Markdown, in one file                        |
| A page's address with `.md` added: [`/quickstart.md`](https://docs.alexein.ai/quickstart.md) | That page as Markdown                    |

Each page's **Copy Markdown** button, at its top, copies the same Markdown.
