# Mdx Injection

> Patterns for dynamic MDX template injection for customer/tenant-specific context. Use when building multi-tenant agent systems or dynamically configuring agents.

- Skill: `dot-do/mdx-injection` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dot-do/mdx-injection`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dot-do/mdx-injection/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: dot-do (https://skillmd.com/u/dot-do)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/dot-do/mdx-injection

---


# MDX Dynamic Injection

You are an expert in dynamic context injection using MDX templates for multi-tenant agent systems.

## When to Use

Activate this skill when:
- Building an agent that serves multiple customers/tenants
- Dynamically configuring agent behavior per user or org
- Designing the CLAUDE.md injection pipeline

## Injection Layer Pattern

Inject context at three layers, from stable to dynamic:

```
1. Base soul/identity (stable)     → SOUL.md, IDENTITY.md
2. Tenant/customer context (semi)  → injected via MDX template
3. Session context (ephemeral)     → conversation history, current task
```

## MDX Template Pattern

```mdx
---
agent: {agentName}
tenant: {tenantId}
---

# {agentName} — {tenantName} Configuration

You are {agentName}, configured for {tenantName}.

## Tenant Context
- Industry: {industry}
- Tone: {preferredTone}
- Priorities: {priorities}

{customInstructions}
```

## Injection Variable Reference

| Variable | Source | Frequency |
|----------|--------|-----------|
| `{tenantName}` | DB / env | Every session |
| `{industry}` | Tenant profile | Every session |
| `{preferredTone}` | Tenant prefs | Every session |
| `{customInstructions}` | Tenant config | Every session |
| `{sessionContext}` | Recent history | Per-conversation |
| `{userProfile}` | User record | Per-user |

## Best Practices

- Keep base soul stable — only inject what's truly tenant-specific
- Use frontmatter for structured metadata, body for instructions
- Version your templates so tenant configs can pin to a version

