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

# Agent skill

> Lurk's skill for coding agents: the habits that keep an integration safe, as a file your agent loads. How to install it.

This page is Lurk's skill for coding agents, in the open Agent Skills format: the habits that keep an integration safe, and why. An agent can read it as Markdown at `https://docs.getlurk.com/agent-skill.md`, and each reference page the same way. To keep it in your repository, see [Install the skill](#install-the-skill) at the end. To connect your own assistant to Lurk as yourself, see [Connect your assistant](https://docs.getlurk.com/connect-your-assistant.md).

Lurk keeps score for an app: it hears what users did (events), runs rules on them, and changes balances of units (beans, XP,
badges) with a receipt for every change. You send events; rules decide what they change.

## Signed in as a person, with no key

If you reach Lurk's MCP server through a person's own sign-in (OAuth) and hold no key, read [`references/member-assistant.md`](https://docs.getlurk.com/agent-skill/member-assistant)
first. Never ask for a key. Use the tools the person's role and connection allow, and pass `project` on each project tool. When the app server needs a project API key, check `lurk.projects.setup`, run `npx @getlurk/cli keys prepare --json`, propose `api_keys.create` via `lurk.apply`, wait for approval, and redeem the approved claim onto the server environment with `npx @getlurk/cli keys claim` without exposing the secret in the conversation. The
reference explains what you can do directly, what you can propose and when the person needs to give the connection more access.

## Before anything else

1. **Work in the project you are told to use.** Each project has its own users, rules and keys. The key prefix does not
   identify the project.
   For a key-based connection, ask an owner or admin to check which project the key belongs to in Lurk.
   A signed-in member can check the project with `projects.get`, using their session and the project ID.
   Want to try something first? Make another project. Each project has its own users and keys. Copy what works across; it arrives as drafts.
   When testing in the project the app uses, use a made-up user: a live rule gives real units.
   For the CLI, use that project's API key and add `--live` if it starts with `lurk_sk_live_`.
2. **Keep the key on the server.** A project key starts with `lurk_sk_` and goes in an environment variable (`LURK_KEY`), sent as
   `Authorization: Bearer …`. Never put it in a browser, a mobile app, a repository or a log. An agent's own key starts with
   `lurk_ak_`. If a key leaked, ask an owner or admin to revoke it in the project's dashboard.
3. **Do not invent what you cannot read.** Look at the project (`GET /v1/rules`, `GET /v1/units`, `GET /v1/events/catalog`, or the
   MCP tools below) before writing a rule or sending an event, and use the unit and event names you find.

TikTok and Instagram are coming to Lurk. Today, the brand's link brings people to its own site or app. Build rewards for what they do there. You can keep someone's handle on their profile.

## Sending an event

`POST /v1/events` with the event, the user, flat properties, and an idempotency key:

```json theme={null}
{
  "event": "order.paid",
  "user": "maya@example.com",
  "properties": { "total_cents": 4200, "venue": "mission-st" },
  "idempotency_key": "order-8841"
}
```

* **Name events** with lowercase words joined by dots, the thing first: `checkin.scanned`, `order.paid`, `signup.completed`. Anything
  else is `validation_failed`.
* **`user` is the app's own identifier** for the person (an email, a user ID). Lurk makes the person on first sight.
  Send the name or email in `profile` if you want Lurk to save it as a profile field.
* **Properties are flat**: strings, numbers, booleans, or short lists of them, at most 50.
* **The idempotency key is what makes a retry safe.** Build it from something that is the same every time the same thing is retried:
  the order ID, the scan ID, the webhook delivery ID. Never `Date.now()` or a random value made per attempt, and never reuse a key
  for a different event (that is `idempotency_conflict`).
* **Read the answer.** `receipts` lists what changed and the balance after. `skipped` says which rules did not apply and why.
  `held` lists changes waiting for a person's decision. Empty receipts are a normal answer.

The fields, the answer and what to read in it are in [`references/events.md`](https://docs.getlurk.com/agent-skill/events).

If the TypeScript SDK (`@getlurk/sdk`) or Python SDK is installed, use it: it makes and reuses idempotency keys, retries only where it
is safe, and checks webhook signatures. Otherwise call the REST API directly.

## Retrying and errors

Errors have a `status`, a `code`, a sentence in `message`, and sometimes a `param` naming the field. Details are in
[`references/errors.md`](https://docs.getlurk.com/agent-skill/errors). The rules of thumb:

* Retry **only** a connection error, `408`, `429` and `5xx`, with the **same** idempotency key and a short growing delay.
  When a wait is supplied, read `Retry-After` on an HTTP `429`, including on the MCP endpoint, or
  `_meta["getlurk.com/retry-after-seconds"]` on a rate-limited MCP tool result. With no wait supplied, use the growing delay.
  Do not retry `validation_failed`, `forbidden`, `not_found` or `idempotency_conflict`. Fix the request or follow its next step.
* `approval_required` means a person must act. With a key, if the operation is on the Proposable list ([`references/rules.md`](https://docs.getlurk.com/agent-skill/rules)),
  make a proposal (`POST /v1/proposals`, or `lurk.apply` over MCP) and give the person the proposal's `url`. Otherwise explain
  the change and ask an owner or admin to do it in the dashboard. With a signed-in assistant, follow the error's `next_step`.

## Rules

A rule is data, in four clauses in this order: **WHEN** (an event, a balance moving, or a schedule), **IF**, **LIMIT**, **DO**. The
full shape and the other kinds are in [`references/rules.md`](https://docs.getlurk.com/agent-skill/rules).

* **Write rules as drafts and preview them.** `POST /v1/rules` makes a draft. `POST /v1/rules/{id}/preview` says what an event rule
  would have given on past events, when a scheduled rule runs next, or what leads into a balance rule. Show the person the preview.
* **You cannot take a rule live, and must not try to.** Going live needs an owner or admin. Ask for it with a proposal
  (`POST /v1/proposals`, or `lurk.apply` over MCP) naming `rules.publish`, and hand the person the link in the answer. Do not look
  for another way.
* **Brand agents never give units by hand.** Rules give. If the user wants a one-off gift, say it is a person's action in the
  dashboard. A signed-in assistant can propose the gift as described in the member assistant reference.
* A unit's rules and limits (`cap`, `min_balance`, `supply`, `expires_after_days`) are the unit's settings, set by a person.
  Propose a change; do not work around a cap by sending extra events.

## Over MCP

For a key-based connection, point the MCP client at `https://api.getlurk.com/mcp` with `Authorization: Bearer <key>`.
See [`references/mcp.md`](https://docs.getlurk.com/agent-skill/mcp) for those tools.

* **Follow the tool's input fields.** If it takes an `idempotency_key`, make one for the call. Use the same one on a retry and a
  new one for a new change.
* **A person decides proposals and takes changes live.** Ask for supported changes with `lurk.apply` and give them the approval
  link. After a person approves an `api_keys.create` proposal, start the claim ([`references/mcp.md`](https://docs.getlurk.com/agent-skill/mcp)) and run `npx @getlurk/cli keys claim` on the server; never read or print the secret in the conversation. A person gives units by hand, undoes changes and revokes keys or manages the team in the dashboard.

## Telling Lurk what is wrong

If you hit a Lurk bug, a confusing error, a docs gap or a missing capability, you may tell the Lurk team with `lurk.feedback.send`
(MCP), `POST /v1/feedback` or `lurk.feedback.send` in an SDK.

* **Ask the person first, once per task.** If they say no, do not send.
* **Never include secrets, keys or the data of the app's users.** Lurk removes what it recognises, but that is best effort, works
  best in English and is not a guarantee. A message that is mostly removed is refused.
* Include the `Request-Id` of the call and the `operation` it is about.
* Lurk staff read it before it is shared in their tracker. No reply is promised and the answer (`received`) carries no status.
* If sending fails, carry on with the task. Do not retry.

The feedback limit on each API server is 5 a minute per project key, agent key or signed-in member in the project.
A member and their connected assistant share the member's limit. Each project can send 50 in 24 hours.

## Trying things without waiting

When the Advanced clock tool is available in your project, ask a person to use it to try streaks, schedules or expiry. They read
the warning and confirm the move. Scheduled rules and expiries can run when time advances. Ask them to reset the clock when done.

## Webhooks

Lurk can tell the server what happened (`activity.created`, `rule.live`, and `unit.used` when someone redeems a unit). Deliveries are signed (Standard Webhooks): check the
signature on the **raw** body before trusting it, answer `2xx` within 10 seconds, and treat the delivery `id` as the key for "have I
seen this" because retries repeat it. Do not parse and re-serialise the body before checking.

## Finish by saying what changed

When you are done, tell the person: which project, what you sent or wrote, which rules are drafts waiting for them, and the link to
approve anything that needs a person.

## Install the skill

The skill is a folder: `SKILL.md` and a `references` folder beside it. Agents that read skills load it when a task needs it. Claude Code reads skills from `.claude/skills/` in your repository; other agents have a folder of their own.

1. Make the folder `.claude/skills/lurk/references`.

2. Save `.claude/skills/lurk/SKILL.md`: this header, then the text of this page from "Signed in as a person, with no key" to the end of "Finish by saying what changed".

   ```markdown SKILL.md theme={null}
   ---
   name: lurk
   description: Integrate an app with Lurk, the rewards and loyalty API. Use when the user wants to send events to Lurk, write or change Lurk rules, read receipts or balances, set up webhooks, or connect an agent to Lurk over MCP. Covers idempotency keys, event names, safe key handling, rules as drafts, and what needs a person to approve.
   ---

   # Working with Lurk
   ```

3. Save each reference page as its file in `.claude/skills/lurk/references`, the text under its title:
   * [`events.md`](https://docs.getlurk.com/agent-skill/events)
   * [`rules.md`](https://docs.getlurk.com/agent-skill/rules)
   * [`mcp.md`](https://docs.getlurk.com/agent-skill/mcp)
   * [`errors.md`](https://docs.getlurk.com/agent-skill/errors)
   * [`member-assistant.md`](https://docs.getlurk.com/agent-skill/member-assistant)

Or ask your agent to do it:

```text theme={null}
Install Lurk's agent skill in this repository. Read https://docs.getlurk.com/agent-skill.md and save it as
.claude/skills/lurk/SKILL.md, as its "Install the skill" section says: the header first, then the skill's text.
Then read each reference page it lists (the same address with .md) and save it as .claude/skills/lurk/references/<name>.md.
```

A saved copy does not update itself: read these pages again when you pick up Lurk work after a while.


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