# Agent prompt

> One prompt for your coding agent that installs the SDK and wires memory into your app.

Paste this into Claude Code, Cursor, Codex or any coding agent, inside your project. It installs the
Geniffy SDK, gives every one of your users a memory of their own, and puts what is known into your
prompts. Set `GENIFFY_API_KEY` in your environment first.

```text
Add long-term memory to this project with Geniffy (docs: https://docs.geniffy.com).

1. Install the SDK for this project's language: `pip install geniffy` (Python) or `npm install geniffy`
   (TypeScript/JavaScript). Read the key from the GENIFFY_API_KEY environment variable; never hard-code
   it, never send it to a browser, and never log it.

2. Create one client for the process and reuse it: `Geniffy()` in Python (or `AsyncGeniffy()` in async
   code), `new Geniffy()` in TypeScript.

3. Give every end user their own memory. Where this app knows which user a request is for, bind a client
   to them once: `mem = client.space(f"user_{user_id}")` in Python, `const mem = client.space(`user_${userId}`)`
   in TypeScript, and use only `mem` below that point. A space is created by the first write to it.
   Never call memory methods on the unbound client for an end user's data: that writes to the account
   owner's own memory, where every user would be mixed together.

4. Save what is worth remembering. After a user tells the app something about themselves, their work or
   their plans, call `mem.memories.add(text)`. To save a whole conversation, pass it as the framework
   holds it: `mem.memories.add(messages=history)` / `mem.memories.add({ messages: history })`. Files:
   `memories.add_file(path)` / `memories.addFile(blob, { filename })` (PDF or Word .docx). Web pages:
   `memories.add(url=...)` / `memories.add({ url })`.

5. Use it before the model answers. Call `mem.context(user_question)` and put the string it returns above
   the user's message in the prompt. It is never empty: when nothing is known it returns a sentence that
   tells the model to say so, so pass it through as is and do not add a fallback. For a direct answer
   instead of context, use `mem.ask(question)`; when its `answer` is null, say nothing is known.

6. Let users be forgotten. Wherever this app deletes a user or their data, also call
   `client.forget_space(f"user_{user_id}")` / `client.forgetSpace(`user_${userId}`)`.

7. Handle errors: catch `AuthenticationError` (a wrong or revoked key) and `UnreadableError` (a file or
   link that could not be read; `error.source.error` says why). The SDK already retries busy and network
   errors. Log the `X-Request-ID` of any failed call: it finds the call on the Requests page.

8. Add one small test that writes a note into a test space, waits with `mem.sources.wait(id)`, checks that
   `mem.context(...)` mentions it, then erases the test space.

Keep the change minimal and match this project's style.
```

## What it asks your agent to do

- Install the SDK for your project's language, and read the key only from `GENIFFY_API_KEY`.
- Bind a client to one space per end user, and never write an end user's data to the unbound client.
- Save what users tell your app, whole conversations as your framework holds them, files and pages.
- Put `context()` above the user's message in your prompt, as it is, with no fallback of its own.
- Call `forget_space` wherever your app deletes a user.
- Catch `AuthenticationError` and `UnreadableError`, and log the request id of any failed call.
- Add one small test that writes to a test space, checks `context()`, and erases the space.

Each of these is explained in [Getting started](https://docs.geniffy.com/getting-started), [Keys and spaces](https://docs.geniffy.com/keys-and-spaces)
and the [Production checklist](https://docs.geniffy.com/production-checklist).

Source: https://docs.geniffy.com/agent-prompt
