insforge-integrations — скилл для Claude Code: как установить
Скилл ведёт агента по подключению чужого провайдера аутентификации к InsForge и по приёму оплаты за HTTP-эндпоинт через x402.
npx skills add InsForge/insforge-skills --skill insforge-integrations -a claude-codeЧто делает insforge-integrations
Скилл даёт агенту отдельную инструкцию под каждого провайдера аутентификации: Clerk, Auth0, WorkOS, Kinde, Stytch, Better Auth. Агент открывает нужный файл в references/ и идёт по шагам — настройка в дашборде, выдача JWT с ID пользователя, передача токена в createClient() через accessToken, политики RLS на функции requesting_user_id().
Вторая часть — платежи по протоколу x402 с фасилитатором OKX. Сервер отдаёт 402 Payment Required с base64-челленджем в заголовке PAYMENT-REQUIRED, клиент подписывает авторизацию EIP-3009, сервер отправляет её на /verify и /settle, а факт оплаты пишет в таблицу с realtime-триггером.
Что понадобится заранее: секрет JWT берётся через npx -y @insforge/cli secrets get JWT_SECRET, для OKX нужен отдельный Web3-ключ из дев-портала, биржевой не подойдёт. Все ID у сторонних провайдеров — строки, поэтому колонки user_id делайте TEXT: с UUID политики просто не создадутся. Для Better Auth после миграции нужен разовый REVOKE, иначе таблица пользователей останется открыта через PostgREST.
Какие задачи решает
- подключить Clerk к InsForge без серверной подписи токенов
- перевести RLS-политики с
auth.uid()наrequesting_user_id() - принять оплату в USDG на X Layer за HTTP-эндпоинт
- защитить таблицу платежей от дублей через
UNIQUEнаtx_hash - прогнать оплату локально без реальных средств на
MOCK_OKX_FACILITATOR
Примеры запросов агенту
- Подключи Clerk к InsForge: JWT-шаблон, `accessToken` в клиенте и RLS-политика на `requesting_user_id()`.
- Заверни этот эндпоинт в `402 Payment Required` и отправь подписанную авторизацию в OKX на `/verify` и `/settle`.
- Проверь мою таблицу платежей: `tx_hash` нужен `UNIQUE`, а ошибку `insert` после расчёта надо логировать.
Как установить insforge-integrations
1Через Skills CLI (Vercel)
npx skills add InsForge/insforge-skills --skill insforge-integrations -a claude-code2Вручную: положить файлы
~/.claude/skills/insforge-integrations/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/insforge-integrations/
1Через Skills CLI (Vercel)
npx skills add InsForge/insforge-skills --skill insforge-integrations -a codex2Вручную: положить файлы
.agents/skills/insforge-integrations/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add InsForge/insforge-skills --skill insforge-integrations -a cursor2Вручную: положить файлы
.cursor/skills/insforge-integrations/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install InsForge/insforge-skills insforge-integrations2Вручную: положить файлы
.github/skills/insforge-integrations/SKILL.md1Через Skills CLI (Vercel)
npx skills add InsForge/insforge-skills --skill insforge-integrations -a gemini-cli2Командой платформы
gemini skills install https://github.com/InsForge/insforge-skills --path skills/insforge-integrationsВручную: положить файлы
.devin/skills/insforge-integrations/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add InsForge/insforge-skills --skill insforge-integrations -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
Похожие
Вопросы о insforge-integrations
Как установить insforge-integrations в Claude Code?
Выполните npx skills add InsForge/insforge-skills --skill insforge-integrations -a claude-code. Файл скилла появится по пути ~/.claude/skills/insforge-integrations/SKILL.md.
Что делает insforge-integrations?
Собирает JWT от стороннего провайдера аутентификации и превращает его в RLS-политики InsForge, а вторым блоком описывает приём оплаты по x402 через OKX. Внутри лежат готовые примеры кода для дашборда, сервера и базы.
Чем Clerk отличается от Better Auth в этом скилле?
Clerk подписывает токены сам через JWT Template, серверный код не нужен. Better Auth крутится в вашем Postgres и требует разового REVOKE после миграции, зато пользовательская таблица остаётся у вас.
Исходный текст
SKILL.md · Apache-2.0
---
name: insforge-integrations
description: >-
Use when wiring an external auth provider (Clerk, Auth0, WorkOS, Kinde,
Stytch, Better Auth) into InsForge for JWT-based RLS, or when adding the
OKX x402 payment facilitator for onchain pay-per-use billing.
license: Apache-2.0
---
# InsForge Integrations
This skill covers integrating **third-party providers** with InsForge. Currently two categories are supported: **auth providers** (RLS via JWT claims) and **payment facilitators** (x402 HTTP payment protocol). Each provider has its own guide under this directory.
## Auth Providers
| Provider | Guide | When to use |
|----------|-------|-------------|
| [Clerk](references/clerk.md) | Clerk JWT Templates + InsForge RLS | Clerk signs tokens directly via JWT Template — no server-side signing needed |
| [Auth0](references/auth0.md) | Auth0 Actions + InsForge RLS | Auth0 uses a post-login Action to embed claims into the access token |
| [WorkOS](references/workos.md) | WorkOS AuthKit + InsForge RLS | WorkOS AuthKit middleware + server-side JWT signing with `jsonwebtoken` |
| [Kinde](references/kinde.md) | Kinde + InsForge RLS | Kinde token customization for InsForge integration |
| [Stytch](references/stytch.md) | Stytch + InsForge RLS | Stytch session tokens for InsForge integration |
| [Better Auth](references/better-auth.md) | Better Auth + InsForge RLS | Self-hosted auth running in your InsForge Postgres — no third-party SaaS, no per-MAU cost |
## Payment Facilitators
| Provider | Guide | When to use |
|----------|-------|-------------|
| [OKX x402](references/okx-x402.md) | OKX as x402 facilitator (USDG on X Layer) | Pay-per-use HTTP endpoints settled onchain with zero gas for the payer |
## Common Patterns
### Auth providers
1. **Provider signs or issues a JWT** containing the user's ID
2. **JWT is passed to InsForge** via `accessToken` in `createClient()` (deprecated alias: `edgeFunctionToken`)
3. **InsForge exposes claims** through `auth.jwt()` in SQL
4. **RLS policies** use a `requesting_user_id()` function to enforce row-level security
### Payment facilitators (x402)
1. **Server returns `402 Payment Required`** with a JSON challenge base64-encoded in `PAYMENT-REQUIRED` header
2. **Client signs an EIP-3009 authorization** using the stablecoin's EIP-712 domain
3. **Server forwards the signed payload** to the facilitator's `/verify` + `/settle` endpoints
4. **Server records the settled payment** in an InsForge table with a realtime trigger for live dashboards
## Choosing a Provider
**Auth**
- **Clerk** — Simplest setup; JWT Template handles signing, no server code needed
- **Auth0** — Flexible; uses post-login Actions for claim injection
- **WorkOS** — Enterprise-focused; AuthKit middleware + server-side JWT signing
- **Kinde** — Developer-friendly; built-in token customization
- **Stytch** — API-first; session-based token flow
- **Better Auth** — Self-hosted in your Postgres; no SaaS vendor; you own the user table. Pairs cleanly with InsForge's Postgres via a connection string + a small bridge route. Requires a one-time `REVOKE` after migrate to seal PostgREST exposure.
**Payment facilitators**
- **OKX x402** — Onchain pay-per-use via USDG on X Layer; zero gas for the payer
## Setup
1. Identify which provider the project uses
2. Read the corresponding reference guide from the tables above
3. Follow the provider-specific setup steps
## Usage Examples
Each provider guide includes full code examples for:
- Provider dashboard configuration (API keys, application settings, etc.)
- Server and client code (JWT utilities for auth; facilitator client + signing utilities for payments)
- Database setup (RLS for auth; payment table + realtime trigger for payments)
- Environment variable setup
Refer to the specific `references/<provider>.md` file for complete examples.
## Best Practices
**Auth**
- All auth provider user IDs are strings (not UUIDs) — always use `TEXT` columns for `user_id`
- Use `requesting_user_id()` instead of `auth.uid()` for RLS policies
- Pass the JWT via `accessToken` — a static string, not a function; for short-lived tokens (Clerk) sync refreshes with `client.setAccessToken(token, AuthChangeEvent.TOKEN_REFRESHED)` after the initial same-user sign-in
- Always get the JWT secret via `npx -y @insforge/cli secrets get JWT_SECRET`
**Payment facilitators (x402)**
- Always check the result of the database `insert(...)` after settlement — settlement takes money onchain before the insert runs; a silent DB failure loses the record
- Add `UNIQUE` to the `tx_hash` column to prevent duplicate records from retries
- Verify EIP-712 domain (`name`, `version`) against the token contract's on-chain `DOMAIN_SEPARATOR` — wrong values produce `Invalid Authority` errors
- Use a `MOCK_OKX_FACILITATOR` env flag for local dev so the full flow can be exercised without real funds
## Common Mistakes
**Auth**
| Mistake | Solution |
|---------|----------|
| Using `auth.uid()` for RLS | Use `requesting_user_id()` — third-party IDs are strings, not UUIDs |
| Using UUID columns for `user_id` | Use `TEXT` — all supported providers use string-format IDs |
| Hardcoding the JWT secret | Always retrieve via `npx -y @insforge/cli secrets get JWT_SECRET` |
| Missing `requesting_user_id()` function | Must be created before RLS policies will work |
**Payments (x402)**
| Mistake | Solution |
|---------|----------|
| Using an OKX exchange trading API key | Create a separate Web3 API key at `web3.okx.com/onchainos/dev-portal` |
| Wrong EIP-712 domain values | Read the token contract's `DOMAIN_SEPARATOR` — for USDG on X Layer use `name: "Global Dollar"`, `version: "1"` |
| Ignoring DB insert error after settlement | Always destructure `{ error }` and log/handle it — money has already moved |
| `MOCK_OKX_FACILITATOR=true` in production | Mock mode is demo-only; it returns fake tx hashes and bypasses verification |
© InsForge · Apache-2.0 · InsForge/insforge-skills