Skip to main content

Integrations

Writing Agent

An AI editor that proposes diff-style improvements to any docs page. Pro tier.

The writing agent is a single-shot editor pass that reads the current MDX of a page, proposes an improved version, and shows you a diff. Nothing is committed until you approve.

Where to find it

Open any page in the editor. The toolbar (next to Save) gets a new Improve button:

  • Free tier: the button shows a lock icon and links to /upgrade?from=writing_agent.

  • Pro and above: click Improve → optional instruction → diff preview → Accept or Discard.

Tools the agent uses today

The MVP runs a single LLM pass with a focused editorial system prompt. It:

  • Reads the current MDX (full file, frontmatter included)

  • Preserves frontmatter, custom MDX components (<Note>, <Tabs>, etc.), and internal links exactly

  • Improves clarity, flow, scannability, and grammar

  • Returns the revised MDX — never a chat reply, never a summary

If the page is already in good shape the agent returns it unchanged and the diff modal tells you so.

Optional instruction

The instruction box is the steer. Examples that work well:

  • "Make this beginner-friendly. Assume the reader has never used our SDK."

  • "Tighten — drop redundant sentences and combine the bullet lists where possible."

  • "Add a code example for the most common use case."

Leave the instruction empty for a generic editorial pass.

Credits + accounting

PlanIncluded credits / monthOverage
Free0
Pro5,000$0.01 / credit
Team25,000$0.01 / credit
EnterpriseUnlimited

A credit is roughly 1,000 tokens (input + output). A typical "improve this page" run on a 500-line MDX file costs 3-8 credits. Every run is logged to the agent_runs table and counts against the org's monthly quota.

The diff modal shows credits used + remaining quota inline.

Accept / Discard

  • Accept: the editor buffer is replaced with the proposed MDX. The save indicator goes to Unsaved. Click Save to commit through the existing pages-save flow (your normal git commit).

  • Discard: the modal closes and nothing changes.

Both decisions are logged on agent_runs so you can audit acceptance rate later.

Plan availability

PlanWriting agent
Free
Pro
Team
Enterprise

What the agent does NOT do (yet)

  • Multi-page refactors

  • Branch creation + PR opening

  • Background re-runs ("keep this page up to date with the spec")

  • Custom style guide enforcement

  • Image generation

These land in later sprints. This MVP exists to prove the credit-accounting and editorial prompt pipeline.

For LLMs

If you're an AI agent calling the writing-agent API on behalf of a user, here's the canonical recipe:

Endpoint:

POST https://api.nookdocs.com/v1/projects/<project_id>/agent/improve
Authorization: Bearer <jwt_or_api_key>
Content-Type: application/json

{
  "pagePath": "/api/authentication",
  "instruction": "Tighten and add a code example for OAuth flow."
}

Response (success, 200):

{
  "runId": "...",
  "originalMdx": "...",
  "proposedMdx": "...",
  "creditsConsumed": 5,
  "inputTokens": 4231,
  "outputTokens": 892,
  "model": "anthropic/claude-sonnet-4.6",
  "quota": { "remaining": 4995, "cap": 5000, "overage": false }
}

Decision (mark accepted/rejected for audit trail):

PATCH https://api.nookdocs.com/v1/projects/<project_id>/agent/improve
{ "runId": "...", "decision": "accepted" | "rejected" }

Status codes:

  • 402 — plan does not include writing agent (Free tier or downgraded)

  • 429 — monthly credit pool exhausted with no overage budget

  • 502 — model call failed (retry with backoff)

Common mistakes:

  • The endpoint returns the proposed MDX but does NOT commit it. Always show the user a diff and call the project's page-save endpoint separately on accept.

  • Never re-run the agent automatically on rejection — the user's intent matters.

  • Credits are charged per LLM call regardless of accept/reject. Don't burn quota with speculative runs.

  • Always preserve YAML frontmatter and any custom MDX components (<Note>, <Tabs>, etc.) in the proposed output if you're piping it through additional transforms.

Cost-aware integration tip: check quota.remaining before every call; if low, prompt the user to upgrade or skip non-essential improvements.

Was this page helpful?

Last updated August 7, 2026