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

# Agent Context Files

> Give AI coding agents like Claude Code, Codex, and Cursor automatic knowledge of your OFAuth setup with an OFAUTH.md file and the OFAuth agent skill.

AI coding agents read context files from your repository to learn your tools and conventions. Give them two things so they build on OFAuth correctly the first time:

* **`OFAUTH.md`**: a project file that records your OFAuth setup: environments, scopes, where tokens live, and your webhook route.
* **The `ofauth` skill**: a set of Markdown files that teaches the agent the OFAuth V3 integration rules. OFAuth publishes it and you install it once.

Both are plain Markdown. Neither contains secrets.

## Frequently Asked Questions

**Which agents read these files?** Claude Code, Codex, Cursor, and other agents that support Agent Skills or project context files such as `AGENTS.md` and `CLAUDE.md`.

**Should I put my client secret in OFAUTH.md?** No. Record the environment variable names only. Secrets belong in your secret manager or server environment.

**What is the difference between the skill and OFAUTH.md?** The skill is the same for everyone: how OFAuth V3 works. `OFAUTH.md` is specific to your project: which environments, scopes, and routes you use.

## OFAUTH.md: Project Context

Add `OFAUTH.md` to your repository root and fill in your values. Then point your agent's main context file at it, for example with this line in `AGENTS.md` or `CLAUDE.md`:

```markdown theme={null}
This project integrates OFAuth V3. Read OFAUTH.md before changing anything that touches OnlyFans accounts, tokens, or webhooks.
```

Template:

```markdown theme={null}
# OFAuth

This project uses OFAuth V3 (https://docs.ofauth.com/v3) to connect OnlyFans accounts.
OFAuth is independent of OnlyFans. Never imply an affiliation in code, UI, or docs.

## Environments

| Environment | Client ID env var | Secret env var | Redirect URI |
| --- | --- | --- | --- |
| Sandbox | OFAUTH_SANDBOX_CLIENT_ID | OFAUTH_SANDBOX_CLIENT_SECRET | http://127.0.0.1:3000/oauth/ofauth/callback |
| Test | OFAUTH_TEST_CLIENT_ID | OFAUTH_TEST_CLIENT_SECRET | https://test.example.com/oauth/ofauth/callback |
| Live | OFAUTH_LIVE_CLIENT_ID | OFAUTH_LIVE_CLIENT_SECRET | https://app.example.com/oauth/ofauth/callback |

Approved integration purpose: "Read the selected OnlyFans profile and inbox"

## Scopes we request

profile:read messages:read messages:write

Add a scope here before calling an operation that needs it.

## Where things live

- Authorization start route: src/app/oauth/ofauth/start/route.ts
- Callback route: src/app/oauth/ofauth/callback/route.ts
- Token storage: the ofauth_authorizations table (refresh token encrypted, authorization_id, environment)
- Linked accounts: the ofauth_linked_accounts table (linked account id, authorization_id, status)
- Webhook receiver: src/app/webhooks/ofauth/route.ts (secret in OFAUTH_WEBHOOK_SECRET)

## Rules

- Use the OFAuth version 4 SDK for this app’s language. The API origin is https://api.ofauth.com.
- Keep client secrets, PKCE verifiers, and refresh tokens server-side.
- Use a durable token store with one authorization per key, including client ID and app user ID.
- Bind authorization start and callback to the same trusted user and browser session.
- Persist tokens normally. Use conditional writes when the customer replaces or disconnects a registration.
- Retry transient refresh failures with the same stable token. An invalid refresh grant requires authorization again.
- List shared accounts, save the user’s choice, and verify that account is still shared before use.
- Verify webhook signatures before parsing. Deduplicate on eventId.
- Branch on recovery.action for errors.
- Develop against Sandbox. Do not log in to real Test accounts repeatedly.
```

## The ofauth Skill

The skill is a folder: `SKILL.md` and a `references/` folder. It is published at `https://ofauth.com/skills/ofauth/`, and `files.txt` in that folder lists every file. Run the install command from your repository root.

> [tab] Claude Code
>
> ```bash theme={null}
> base=https://ofauth.com/skills/ofauth dir=.claude/skills/ofauth; curl -fsSL "$base/files.txt" | while read -r f; do curl -fsSL --create-dirs -o "$dir/$f" "$base/$f" || exit 1; done
> ```
>
> Claude Code loads skills from `.claude/skills/`. To use the skill in every project, set `dir=~/.claude/skills/ofauth` instead.

> [tab] Codex and others
>
> ```bash theme={null}
> base=https://ofauth.com/skills/ofauth dir=.agents/skills/ofauth; curl -fsSL "$base/files.txt" | while read -r f; do curl -fsSL --create-dirs -o "$dir/$f" "$base/$f" || exit 1; done
> ```
>
> Codex and other agents that support Agent Skills load skills from `.agents/skills/`. If your agent does not load skills, add this line to your `AGENTS.md`:
>
> ```markdown theme={null}
> When working on the OFAuth integration, follow .agents/skills/ofauth/SKILL.md and read the reference files it links.
> ```

> [tab] Cursor
>
> Download the files with the **Codex and others** command, then add a rule at `.cursor/rules/ofauth.mdc`:
>
> ```markdown theme={null}
> ---
> description: Working on the OFAuth V3 integration
> globs:
> alwaysApply: false
> ---
> When working on the OFAuth integration, follow .agents/skills/ofauth/SKILL.md and read the reference files it links.
> ```

On Windows, run the command in Git Bash or WSL.

## Start Building

Open your agent in the repository and paste:

```text theme={null}
Add OFAuth V3 to this app using the ofauth skill. Start in Sandbox. Show me the plan before you edit code, use placeholders for every secret, and create OFAUTH.md when you are done.
```

## Learn More

* [Welcome, agent](https://docs.ofauth.com/v3/agents/playbooks/welcome-agent-get-started.md)
* [Which OFAuth setup do I need?](https://docs.ofauth.com/v3/agents/playbooks/choosing-an-ofauth-setup.md)
* [V3 overview](https://docs.ofauth.com/v3.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.