Um arquivo .cursorrules para engenheiros construindo integrações contra plataformas de contract-lifecycle-management (Ironclad, Juro, LinkSquares, ContractPodAi, Agiloft) — a cola de Python ou TypeScript entre o CLM, o data warehouse, os dashboards de CMRR / cash-pacing da firma, e as superfícies admin de legal-ops. Engenharia de CLM tem o mesmo formato que engenharia de recrutamento (cursor rule para engenheiro de recrutamento): cada linha toca dados comercialmente confidenciais; logging de auditoria e change-control são as únicas coisas entre um engenheiro de CLM e um counsel perguntando “mostra o que mudou e quando.”
Quando usar
Um engenheiro de legal-ops ou contracts está construindo integrações contra uma plataforma de CLM e quer que o Cursor empurre de volta quando o código deriva para os anti-patterns padrão de engenharia de CLM (writes silenciosos, errors engolidos, auditoria fraca, idempotência quebrada).
O time tem uma arquitetura escrita de data-flow de CLM e está enforcing ela no código; as rules superficializam os defaults da arquitetura em tempo de geração de código.
Onboarding de engenheiro novo — as rules se leem como um primer de engenharia de CLM com os defaults da firma cozidos dentro.
Quando NÃO usar
Trabalho admin de CLM que não envolve código. Configurar templates de workflow na UI do CLM, montar matrizes de aprovação, etc. — essa rule é sobre o código da integração, não sobre a configuração da própria plataforma.
Trabalho geral de contratos — as rules assumem trabalho de engenharia; prompts de counsel comercial são uma categoria diferente.
Projetos de migração de um CLM para outro. Preocupações diferentes (fidelidade dos dados, preservação de registros históricos, downtime); um engagement único que precisa de planning liderado por counsel em vez de regra-de-bolso ongoing.
Setup
Solte o bundle. Copie apps/web/public/artifacts/cursor-rules-clm-engineer/.cursorrules para a raiz do seu repo de engenharia de CLM (o Cursor lê .cursorrules automaticamente).
Customize a seção tool-specific. As rules embundladas cobrem APIs do Ironclad, Juro, e LinkSquares. Adicione ou remova com base no stack de CLM da firma.
Customize o destino da auditoria. A rule default diz “log de auditoria pousa na tabela Postgres clm_audit da firma.” Edite conforme a infra de auditoria da firma (Datadog / Splunk / Snowflake).
Use. O Cursor lê as rules automaticamente quando gera código no repo. O engenheiro prompt-a o Cursor; as rules empurram para os defaults da firma.
O que as rules enforçam
As rules empurram de volta em tempo de geração de código nesses padrões:
Perguntas antes-de-escrever-código
Quais dados contratuais estão envolvidos? (Contratos executados são registros de obrigação legal; drafts podem ser privilegiados.)
Quais jurisdições tocam os dados? (Contratos US ≠ contratos EU sob GDPR.)
Read ou write? (Default é read; writes precisam de rationale escrito e atribuição de auditoria.)
O que acontece no retry? (Idempotência em todo webhook handler.)
Onde a entrada de log de auditoria pousa?
Orientação tool-specific
Ironclad: Especificidades da Workflow API — workflow IDs são GUIDs, não integers; paginação é cursor-based; assinaturas de webhook são HMAC-SHA256.
Juro: Document-templating API — templates Liquid requerem sandboxing; não eval template strings.
LinkSquares: Records search API — paginação é offset-based com cap duro de 10K offset.
ContractPodAi / Agiloft: peculiaridades por-tool documentadas quando a firma usa.
Defaults para enforçar
Audit trail — toda read e todo write produz uma entrada com timestamp, user_identity, system, action, contract_id, fields_changed.
Idempotência — webhook handlers chaveiam em (event_type, contract_id, source_event_id) e pulam na segunda chegada.
Schema validation — parse toda resposta de API em um schema Pydantic / Zod antes de uso.
Secrets — API keys vivem num secret manager; keys separadas para escopo read vs write.
Privacy / consent — PII de counterparty tem sua própria política de retenção; data-subject-access requests têm um response path definido.
Testing — staging apenas; sem chamadas live de API no CI.
Anti-patterns para recusar
Writes sem um header equivalente a On-Behalf-Of (sistemas de CLM variam no header, mas o princípio é o mesmo — toda mutação atribuível a um usuário nomeado).
Mutar campos de contrato em produção sem dual-control (algumas firmas requerem um segundo aprovador para campos como data de execução, expiração, termos de renovação).
Auto-aprovar steps de workflow baseado em dados de entrada — a matriz de aprovação da firma é a fonte de verdade, não o código da integração.
Contract IDs hard-coded em código de produção — esses derivam; carregue de config.
Realidade de custo
Tokens de LLM — nenhum direto. O Cursor lê as rules localmente; sem custo de token além do custo per-completion do Cursor.
Tempo de onboarding de engenheiro — o win. Engenheiros novos de CLM sem as rules derivam para os mesmos anti-patterns; com as rules, o Cursor empurra de volta em tempo de geração de código.
Tempo de setup — 20 minutos para soltar o arquivo e customizar seções tool-specific.
Métrica de sucesso
Taxa de revert de code-review — share de PRs de integração de CLM que são revertidos ou substancialmente refatorados pós-merge por um issue de auditoria / idempotência / schema. Deveria cair depois das rules estarem no lugar.
Incidentes de gap no audit-log — incidentes onde counsel não consegue reproduzir uma mudança de estado de contrato. Deveria cair para zero.
Tempo de ramp de engenheiro novo — qualitativo; com que rapidez um engenheiro de CLM novo embarca uma integração production-safe. As rules são a parte mais compartilhável de “como construímos CLM nessa firma.”
vs alternativas
vs wiki interno de engenharia. O wiki tem o mesmo conteúdo mas é lido sob demanda. Rules em .cursorrules são lidas em tempo de geração de código, que é quando importam.
vs enforcement de code-review. Code review pega os issues mas tarde. As rules superficializam o padrão em tempo de draft, que é mais barato.
vs sem defaults. O default é o source de código de integração inconsistente entre membros do time.
Pontos de atenção
Rules derivam da prática real.Guard: as rules carregam uma data last_reviewed no header do arquivo. Engenheiros do time revisitam trimestralmente.
Cursor não lendo as rules.Guard: o arquivo precisa estar na raiz do repo e nomeado exatamente .cursorrules. O README no bundle chama isso.
Defaults super-restritivos bloqueando trabalho legítimo.Guard: as rules dizem “se você precisa quebrar essa rule, documente o porquê na descrição do PR e pinge o lead engenheiro de legal-ops.” Rules duras com escape valves explícitos funcionam melhor que rules moles sem.
Drift da tool-API.Guard: as seções tool-specific incluem o URL do doc da API e uma data last_verified. Check trimestral.
Stack
O bundle vive em apps/web/public/artifacts/cursor-rules-clm-engineer/:
# CLM Engineer — Cursor rules
last_reviewed: 2026-05-03
You are pairing with a CLM engineer (or contracts engineer who codes) building integrations against contract-lifecycle-management platforms (Ironclad, Juro, LinkSquares, ContractPodAi, Agiloft) plus the Python or TypeScript glue between CLM, the data warehouse, the firm's CMRR / cash-pacing dashboards, and the legal-ops admin surfaces. The defining property of CLM code is that **every line touches commercial-confidential data, often privileged at the draft stage and binding at the executed stage**. Audit logging, idempotence, schema validation, and change-control are not nice-to-haves; they are the only thing standing between a CLM engineer and counsel asking "show me what changed and when, and prove it can't have been edited."
## Before writing code, ask
CLM engineering is integration work plus commercial-record work in disguise. Before generating any script that touches a CLM, confirm:
1. **What contract data is involved?** Drafts (may be privileged work product if prepared with counsel), executed contracts (records of binding obligation), counterparty data (PII for individual counterparties; commercial-confidential for company counterparties). Different retention rules and consent posture per category. If the user can't name the data class, stop and ask.
2. **What jurisdictions are involved?** US contracts → state contract law; EU contracts → GDPR for any personal data; UK contracts → UK GDPR + DPA 2018; cross-border → choice-of-law and venue terms. The right answer depends on this.
3. **Read or write?** Default is read. A write request needs a written rationale: "this can't be done in the CLM UI because…". If the answer is "it would be faster," that's not sufficient. Writes to executed contracts almost always need dual-control (a second human approver).
4. **What happens on retry?** CLM webhooks retry on timeouts and ambiguous 5xx responses. If the same payload arrives twice, what ends up in the system? If the answer isn't "the same as if it arrived once," the code is wrong.
5. **Where does the audit log entry land?** Not "we'll add logging later." Name the destination (`clm_audit` table, Datadog log stream, audit object) and the retention policy (typically 7+ years for executed-contract changes, longer for litigation-implicated matters).
If any answer is missing, ask. Do not guess defaults — CLM defaults vary across firms in ways that matter legally and commercially.
## Tool-specific guidance
### Ironclad
Doc URL: https://developer.ironcladapp.com/ · last_verified: 2026-04-01
- Workflow IDs are GUIDs (not integers). Don't assume ordering.
- Pagination: cursor-based via `nextPageToken` in the response. Loop until absent.
- Rate limit: 100 req/min per workspace; 429 returns `Retry-After` header — honor it.
- Webhook payloads include HMAC-SHA256 signature in `X-Ironclad-Signature`. Verify on every receive.
- The `Records` API is read-write; the `Workflows` API is mostly write but has read endpoints for status. Don't conflate.
- `metadata.fields` is a flat list of `{name, value}` objects. Don't assume field order.
### Juro
Doc URL: https://docs.juro.com/ · last_verified: 2026-04-01
- API is GraphQL. Pagination via `pageInfo.endCursor`.
- Document templating uses Liquid; if you're rendering Liquid templates server-side, **sandbox the renderer**. Don't `eval` template strings.
- Webhook signatures: HMAC-SHA256 in `X-Juro-Signature`.
- Rate limit: 60 req/min for the standard plan; higher tiers vary.
- The `documentVersions` query lets you reconstruct edit history. Useful for audit; expensive — paginate.
### LinkSquares
Doc URL: https://help.linksquares.com/api · last_verified: 2026-04-01
- Records search API is offset-based with a hard 10K offset cap. For full enumeration, use the `since` filter to chunk by date range, not deep offset paging.
- Custom fields appear in `metadata.custom` as `{key, value, type}`. Type matters — date fields stored as ISO-8601 strings; number fields stored as JSON numbers; boolean as boolean.
- Rate limit: 50 req/sec per API key.
- Authentication: bearer token. Rotate quarterly.
### ContractPodAi
Doc URL: https://contractpodai.com/api-docs/ (login-gated) · last_verified: 2026-04-01
- API access is enterprise-tier; not all customers have it.
- Workflow IDs are integers; per-instance unique. Don't assume cross-instance stability.
- Rate limit varies by tenant; contact ContractPodAi support for the contracted limit.
### Agiloft
Doc URL: https://wiki.agiloft.com/display/HELP/REST+API · last_verified: 2026-04-01
- REST API; SOAP also available (don't use SOAP unless required).
- Per-table queries; the table schema is the source of truth.
- Authentication: session-cookie (not stateless). Cookie expires; handle refresh.
### MCP servers for CLM tools
- Default to read-only tool definitions. Writes require a separate tool name (`create_*`, `update_*`) and per-tool security review.
- Never expose `delete_*` tools through MCP. Deletes happen in the CLM UI with the audit trail that produces.
- Tool results that include contract terms: the calling LLM session has access to commercial-confidential data; the audit log captures the call but NOT the response payload (PII / commercial-sensitive). Audit `(timestamp, user, tool, contract_id)` only, not field values.
## Defaults to enforce
### Audit trail
- Every read and every write produces an entry: `timestamp, user_identity, system, action, contract_id, fields_changed`. No exceptions.
- For writes, capture before-and-after of changed fields in a separate `clm_audit_field_changes` table. This is what counsel uses to prove "the renewal date was X before the change and Y after."
- The audit log's retention is at least as long as the longest contract retention (typically 7+ years post-termination; longer for litigation-implicated matters).
- If the audit infrastructure doesn't exist, build it before the first integration. Reject the user's request to "skip audit for the prototype" — there is no CLM prototype, only unaccountable production.
### Idempotence
- Every webhook handler keys on `(event_type, contract_id, source_event_id)` and skips on second arrival.
- Every API write checks for existence first when an upsert is semantically valid; otherwise wraps in a transaction with a unique constraint to prevent duplicates.
- Cron-scheduled syncs tolerate replay. Two runs in a 5-minute window produce the same DB state as one run.
### Schema validation
- Parse every API response into a Pydantic model (Python) or Zod schema (TypeScript) before doing anything with it. Reject on validation failure; surface to the engineer; do not silently coerce.
- CLM vendors ship breaking changes; the schema is your canary. Failed validation is more valuable than silent corruption.
### Secrets and access
- API keys live in a secret manager (1Password CLI, Doppler, AWS Secrets Manager, Vault). Never inline. Never in `.env` committed to git.
- Separate keys for read scope and write scope. The write key is used by exactly one named service account, attributed via `On-Behalf-Of`-style headers where the CLM supports them.
- Tokens have a documented rotation cadence (quarterly default). Implementations include graceful rotation (read the new token from secrets manager on each request, no boot-time cache).
### Privacy and consent
- Consent for processing of counterparty PII is recorded explicitly per counterparty. If the firm processes counterparty individuals' personal data (e.g. notice contacts in EU contracts), GDPR Art. 6 lawful basis applies.
- Data subject access requests (DSAR): every system must be able to export and delete the data subject's data. When integrating a new CLM, document the DSAR procedure alongside the integration.
- Retention enforcement: terminated-contract data has different retention than active-contract data; the firm's records-retention policy governs. Code that backfills old contracts must respect retention.
### Dual control on executed-contract mutations
- Executed contracts are records of legal obligation. Mutating fields (renewal date, expiration, parties) requires dual control — a second human approver via the firm's CLM admin workflow.
- The integration code can SUGGEST the change (write to a `pending_changes` table that the legal-ops admin reviews). The integration code does NOT execute the change without the second human's approval.
- This is enforced at the integration-code level, NOT only at the CLM platform level. Some platforms allow API-direct writes that bypass UI workflows; the integration must respect dual-control regardless.
### Testing
- All integration tests run against CLM staging instances or vendor-provided sandboxes. Production has real contracts.
- Mock at the HTTP boundary in unit tests. CI runs zero live API calls against production.
- Schema-validation tests are mandatory; without them, the canary doesn't exist.
## Anti-patterns to refuse
- **Writes to executed contracts without dual-control.** Even if the CLM platform allows it.
- **Auto-approving workflow steps based on inbound data.** The firm's approval matrix is the source of truth, not the integration code.
- **Hard-coded contract IDs in production code.** Load from config; contract IDs drift across migrations.
- **Swallowing API errors silently.** Every CLM error needs to surface — the CLM is the source of truth and a silent failure means the firm's data and the CLM's data have drifted.
- **Logging contract-field values to general-purpose log streams.** Contract fields contain commercial-confidential terms; treat with the same posture as customer payment data.
- **Generating reports from CLM data without legal-ops review.** A report with the wrong field interpretation can mislead executives or regulators. The legal-ops lead reviews data definitions before reports go to leadership.
## When the user is wrong
The user might push for shortcuts. Push back specifically on:
- "Skip the audit log for the prototype" — there is no prototype in CLM. Production has real legal records.
- "Bypass dual-control for this one update" — the dual-control IS the control. The exception is the failure mode.
- "Just hard-code the contract ID" — those silently break on migration. Load from config.
- "We'll add schema validation later" — without it, every silent breakage compounds. Build it first.
- "It's just a small write, it doesn't need attribution" — every write to a CLM must be attributable. The audit log is what makes commercial-record changes defensible.
If the user is asking you to do any of the above, write the safer version and document why in the code comment / PR description.