AI integration
Most ConsentLoop installs will be done by an AI pair — Claude, Cursor, Copilot, or an autonomous agent. The product is designed for that: one obvious API, machine-readable contracts, and nothing that requires reading source code to get right.
Point your assistant at the contracts
| Artifact | URL / path | Use |
|---|---|---|
llms.txt | /llms.txt | Index + integration rules (llmstxt.org format) |
llms-full.txt | /llms-full.txt | The entire documentation as one plain-text file — paste into any context window |
| JSON Schema | /consentloop.schema.json | Validate configs; editor autocomplete via $schema |
| TypeScript types | consentloop/dist/index.d.ts | Fully JSDoc’d — agents can read intent, not just shape |
One-shot prompt
Paste this into your assistant inside your project:
Add cookie consent to this project using ConsentLoop (npm: consentloop, docs: https://consentloop.dev/llms-full.txt). Requirements: 1. Categories: necessary (required), analytics, marketing. 2. Gate every existing analytics/marketing script with type="text/plain" + data-consent + data-consent-src. 3. Enable googleConsentMode if Google tags are present, and load ConsentLoop before them. 4. Add a "Cookie settings" footer link calling ConsentLoop.showPreferences(). 5. GDPR defaults: keep showRejectAll on; do not preselect optional categories. If this is a React app, use @consentloop/react's ConsentProvider and ConsentGate instead of data-attributes for embeds.
Why agents get it right first try
- One entry point:
ConsentLoop.run(config)— no builder chains, no imperative setup order. - Declarative gating:
data-consentattributes are grep-and-rewrite friendly; no code-flow analysis needed. - Self-diagnosing: in dev, unknown config keys and gated-but-unconfigured categories log actionable
console.warns the agent can read and fix. - Deterministic selectors: stable
data-aattributes (accept-all,reject-all,open-prefs,save) inside a stable#consentloophost — browser agents and E2E tests never guess. - Typed everything: strict TS with JSDoc on every field;
defineConfig()for typed configs in plain JS.
Driving the widget in E2E / browser agents
// Playwright — the widget lives in an open shadow root under #consentloop
const root = page.locator("#consentloop");
await root.locator('[data-a="accept-all"]').click();
// or skip the UI entirely:
await page.evaluate(() => window.ConsentLoop.acceptAll());
// assert state
const accepted = await page.evaluate(() => window.ConsentLoop.acceptedCategories());
Config validation in CI
// validate-consent.mjs — run in CI with your schema validator of choice
import { readFileSync } from "node:fs";
import Ajv from "ajv";
const schema = JSON.parse(readFileSync("node_modules/consentloop/schema.json", "utf8")); // or fetch /consentloop.schema.json
const valid = new Ajv({ allowUnionTypes: true }).compile(schema)(myConfig);
MCP & automation
Because state is a readable first-party cookie and every transition emits a DOM event (consentloop:consent, consentloop:change…), monitoring agents can observe consent without any SDK. The adapter contract is two plain HTTP calls — trivial for an agent to implement against your backend.