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

# Prompt Registry

> Manage and version your prompts centrally.

The Prompt Registry lets you manage prompts centrally, separate from your code. Update prompts without redeploying your application.

## Why Use Prompt Registry?

* **Iterate faster** - Update prompts without code changes
* **Version control** - Track prompt history and rollback
* **A/B testing** - Test different prompts in production
* **Collaboration** - Non-engineers can edit prompts

## Creating a Prompt

1. Go to **Prompt Registry** in your project
2. Click **New Prompt**
3. Enter a name (e.g., `summarization-system-prompt`)
4. Write your prompt content
5. Click **Save**

## Prompt Structure

Each prompt has:

* **Name** - Unique identifier (slug format)
* **Content** - The prompt text
* **Variables** - Placeholders like `{{user_name}}`
* **Version** - Auto-incremented on each save
* **Tags** - For organization

## Using Variables

Include variables in your prompts:

```
You are a helpful assistant for {{company_name}}.
The user's name is {{user_name}}.
```

Pass variables when fetching:

```python theme={null}
from muxx import Muxx

muxx = Muxx()

prompt = muxx.get_prompt(
    "welcome-message",
    variables={
        "company_name": "Acme Corp",
        "user_name": "Alice"
    }
)
# Returns: "You are a helpful assistant for Acme Corp.\nThe user's name is Alice."
```

## Fetching Prompts

### Python

```python theme={null}
from muxx import Muxx

muxx = Muxx()

# Get latest version
prompt = muxx.get_prompt("summarization-system-prompt")

# Get specific version
prompt = muxx.get_prompt("summarization-system-prompt", version=3)

# Use in LLM call
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": prompt},
        {"role": "user", "content": user_input}
    ]
)
```

### TypeScript

```typescript theme={null}
const muxx = new Muxx();

const prompt = await muxx.getPrompt('summarization-system-prompt');

const response = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [
    { role: 'system', content: prompt },
    { role: 'user', content: userInput },
  ],
});
```

## Versioning

Every save creates a new version:

| Version | Date      | Author | Note                |
| ------- | --------- | ------ | ------------------- |
| v3      | Today     | Alice  | Added tone guidance |
| v2      | Yesterday | Bob    | Fixed typo          |
| v1      | Last week | Alice  | Initial version     |

### Rollback

To rollback to a previous version:

1. Click the version in history
2. Click **Restore**
3. This creates a new version with the old content

## Environments

Use different prompts per environment:

```python theme={null}
# Production uses v3 (stable)
prompt = muxx.get_prompt("system-prompt", environment="production")

# Staging uses latest
prompt = muxx.get_prompt("system-prompt", environment="staging")
```

## Caching

Prompts are cached locally to minimize latency:

* Default TTL: 60 seconds
* Force refresh: `muxx.get_prompt("name", cache=False)`

## Best Practices

<AccordionGroup>
  <Accordion title="Use descriptive names">
    `customer-support-system-v2` is better than `prompt1`.
  </Accordion>

  <Accordion title="Document with tags">
    Use tags like `production`, `experimental`, `deprecated`.
  </Accordion>

  <Accordion title="Test before promoting">
    Test new versions in staging before production.
  </Accordion>

  <Accordion title="Keep prompts focused">
    One prompt per purpose. Don't combine unrelated instructions.
  </Accordion>
</AccordionGroup>
