Automatically keep your Mintlify documentation in sync with code changes using SpinAI. This agent watches your pull requests and automatically creates documentation updates when code changes.
- π€ Automatic documentation updates based on code changes
- π Intelligent analysis of code and documentation relationships
- π Automatic navigation updates in
mint.json
- π― Smart prioritization of documentation updates
- π¨ Maintains your existing documentation style
- ποΈ Supports monorepo setups
- Create a new project:
npx create-spinai
-
Select
mintlify-docs-updater
from the template options. -
Set up environment variables in
.env
:
# Edit .env with your keys:
# OPENAI_API_KEY=your-openai-key
# GITHUB_TOKEN=your-github-token
To get a GitHub token:
-
Go to GitHub Settings > Developer Settings > Personal Access Tokens > Tokens (classic)
-
Click "Generate new token (classic)"
-
Give it a name (e.g., "Mintlify Doc Updater")
-
Select these permissions:
- For public repositories:
public_repo
- For private repositories:
repo
- Also select:
read:org
if you're using it with organization repositories
- For public repositories:
-
Copy the token and add it to your
.env
file -
Configure the agent in
src/config.ts
:
// For a standard Mintlify setup (docs in same repo)
export const defaultConfig: Required<DocConfig> = {
docsPath: "docs", // Path to your Mintlify docs
isMonorepo: false,
docsRepoOwner: "your-username", // Your GitHub username or org
docsRepoName: "your-repo", // The repository name
docsBranch: "main",
fileTypes: [".mdx", ".md"],
ignorePaths: ["**/node_modules/**"],
createNewPr: true,
labels: ["documentation"],
styleGuide: "",
};
// For a monorepo setup (e.g., docs in apps/docs)
export const defaultConfig: Required<DocConfig> = {
docsPath: "apps/docs", // Adjust to your monorepo docs path
isMonorepo: true,
docsRepoOwner: "",
docsRepoName: "",
docsBranch: "main",
fileTypes: [".mdx", ".md"],
ignorePaths: ["**/node_modules/**"],
createNewPr: true,
labels: ["documentation"],
styleGuide: "",
};
// For docs in a separate repository
export const defaultConfig: Required<DocConfig> = {
docsPath: "docs",
isMonorepo: false,
docsRepoOwner: "your-org", // Owner of the docs repo
docsRepoName: "docs", // Name of the docs repo
docsBranch: "main",
fileTypes: [".mdx", ".md"],
ignorePaths: ["**/node_modules/**"],
createNewPr: true,
labels: ["documentation"],
styleGuide: "",
};
-
Configure GitHub webhook:
- Go to your repository settings
- Add webhook:
http://your-server:3000/webhook
(use ngrok for local development) - Select events: "Pull requests"
- Content type: "application/json"
-
Start the server:
npm run dev
# or
yarn dev
That's it! The agent will now automatically review pull requests and create documentation updates.
The agent accepts a simple configuration object:
interface DocConfig {
// Essential settings
docsPath: string; // Path to docs (e.g., "docs" or "apps/docs")
isMonorepo?: boolean; // Is this a monorepo setup?
// Repository settings (optional)
docsRepoOwner?: string; // GitHub owner of docs repo if different
docsRepoName?: string; // Name of docs repo if different
docsBranch?: string; // Branch to update (defaults to 'main')
// Documentation settings
fileTypes?: string[]; // Doc file types (defaults to ['.mdx', '.md'])
ignorePaths?: string[]; // Paths to ignore
// PR settings
createNewPr?: boolean; // Create new PR vs update original
labels?: string[]; // Labels to add to PR
// Optional customization
styleGuide?: string; // Custom documentation style guide
}
If you want to use the agent without the server:
import { createDocUpdateAgent } from "mintlify-doc-updater";
const agent = createDocUpdateAgent({
config: {
docsPath: "docs"
}
});
// Use the agent directly
const result = await agent({
input: "Review pull request #123",
externalCustomerId: "user123",
state: {
owner: "org",
repo: "repo",
pull_number: 123,
config: {} // Will be populated from your config
}
});
OPENAI_API_KEY
(required): Your OpenAI API keyGITHUB_TOKEN
(required): GitHub token with repo accessPORT
(optional): Server port (default: 3000)SPINAI_API_KEY
(optional): SpinAI API key for monitoring and observability. Get one at app.spinai.dev
The GitHub token needs these permissions:
repo
scope for private repositoriespublic_repo
scope for public repositories
For production use, we recommend setting up a GitHub App:
- Create a new GitHub App
- Configure permissions:
- Pull requests: Read & write
- Contents: Read & write
- Metadata: Read-only
- Subscribe to events:
- Pull request
- Pull request review
- Install the app on your repositories
- Use the app's credentials instead of a personal token
When a pull request is opened or updated, the agent:
- Analyzes code changes to understand what functionality changed
- Scans existing documentation structure and relationships
- Plans necessary documentation updates
- Generates precise, accurate documentation updates
- Updates navigation structure in
mint.json
if needed - Creates a new PR with all documentation changes
We welcome contributions! Please see our Contributing Guide for details.
MIT License - see LICENSE for details.