Skip to content

API Reference ​

Claude Plan Viewer exposes a REST API for programmatic access to your Claude Code plans. The API is designed for fast initial loads with lazy content fetching.

OpenAPI Specification

The full OpenAPI 3.0 specification is available:

  • Interactive: API Playground - try out endpoints directly
  • Download: openapi.json (for import into API tools, available on docs site)
  • Live: /api/openapi.json when the server is running

Base URL ​

All API endpoints are relative to the server root. By default, the server runs on http://localhost:3000.


List Plans ​

GET /api/plans

Returns metadata for all plans without content. This endpoint is optimized for fast initial page loads.

Response ​

Returns an array of plan metadata objects:

FieldTypeDescription
filenamestringPlan filename (e.g., my-plan.md)
filepathstringAbsolute path to the plan file
titlestringPlan title extracted from the first markdown heading
sizeintegerFile size in bytes
modifiedstringLast modification timestamp (ISO 8601 format)
createdstringCreation timestamp (ISO 8601 format)
lineCountintegerNumber of lines in the plan
wordCountintegerNumber of words in the plan
projectstring | nullAssociated Claude Code project name, if any
sessionIdstring | nullAssociated Claude Code session ID, if any

Example Response ​

json
{
  "plans": [
    {
      "filename": "refactor-auth-module.md",
      "filepath": "/Users/dev/.claude/plans/refactor-auth-module.md",
      "title": "Refactor Authentication Module",
      "size": 4521,
      "modified": "2025-01-15T14:32:00.000Z",
      "created": "2025-01-10T09:15:00.000Z",
      "lineCount": 142,
      "wordCount": 856,
      "project": "my-webapp",
      "sessionId": "abc123-def456"
    },
    {
      "filename": "api-redesign.md",
      "filepath": "/Users/dev/.claude/plans/api-redesign.md",
      "title": "API Redesign Plan",
      "size": 2103,
      "modified": "2025-01-14T11:20:00.000Z",
      "created": "2025-01-14T10:00:00.000Z",
      "lineCount": 67,
      "wordCount": 412,
      "project": null,
      "sessionId": null
    }
  ]
}

Use Cases ​

  • Initial page load: Fetch all plan metadata to display in a list or table
  • Building search indexes: Index plans by title, project, or timestamps
  • Filtering and sorting: Client-side filtering by project, date range, or size

Get Plan Content ​

GET /api/plans/{filename}/content

Returns the full markdown content for a specific plan. Use this endpoint to fetch content on-demand when a user selects a plan.

Path Parameters ​

ParameterTypeRequiredDescription
filenamestringYesThe plan filename (e.g., my-plan.md)

Response ​

FieldTypeDescription
contentstringThe full markdown content of the plan

Example Request ​

bash
curl http://localhost:3000/api/plans/refactor-auth-module.md/content

Example Response ​

json
{
  "content": "# Refactor Authentication Module\n\n## Goals\n\n- Migrate from session-based to JWT authentication\n- Implement refresh token rotation\n- Add rate limiting to login endpoint\n\n## Tasks\n\n- [ ] Create JWT utility functions\n- [ ] Update user model with refresh token field\n- [ ] Modify login endpoint\n- [ ] Add token refresh endpoint\n- [ ] Update middleware\n\n## Notes\n\nConsider using RS256 for production..."
}

Error Responses ​

StatusDescription
404Plan not found

Use Cases ​

  • Lazy loading: Fetch content only when a plan is selected
  • Markdown rendering: Get raw content for client-side rendering
  • Content export: Download plan content for external use

Search Plan Content ​

GET /api/search?q={query}

Returns the filenames of plans whose markdown content contains the query (case-insensitive). The web UI combines this with client-side matching on title, filename, and project.

Query Parameters ​

ParameterTypeRequiredDescription
qstringYesSearch text; an empty query returns no matches

Example Request ​

bash
curl "http://localhost:3000/api/search?q=jwt"

Example Response ​

json
{
  "filenames": ["refactor-auth-module.md"]
}

List Memory ​

GET /api/memory

Returns Claude Code's auto memory: one source per memory directory and one entry per file, without content. Sources come from ~/.claude/projects/*/memory/ and any autoMemoryDirectory setting. Results are cached for 5 seconds; POST /api/refresh clears the cache.

Response ​

FieldTypeDescription
sourcesMemorySource[]Memory directories, sorted by project name
entriesMemoryEntry[]Files in those directories, including each MEMORY.md

MemorySource

FieldTypeDescription
idstringProject directory name, or custom-<hash> for an autoMemoryDirectory
kind"project" | "custom"Default project directory or autoMemoryDirectory
projectstringProject name from the session cwd; All projects for a user-level autoMemoryDirectory
cwdstring | nullWorking directory of the project
dirstringAbsolute path of the memory directory
activebooleanfalse when an autoMemoryDirectory setting means Claude Code no longer reads it
indexobject | nullMEMORY.md stats: lines, bytes, lineLimit (200), byteLimit (25000), danglingLinks
orphansstring[]Topic files MEMORY.md doesn't link to
entryCountnumberTopic files, excluding MEMORY.md
modifiedstringLatest modification of any entry (ISO 8601)

MemoryEntry

FieldTypeDescription
idstring<sourceId>/<filename>
sourceIdstringSource this entry belongs to
filename / filepathstringFile name and absolute path
isIndexbooleantrue for MEMORY.md
namestringFrontmatter name, else the first heading, else the filename
descriptionstring | nullFrontmatter description
typestring | nulluser, feedback, project, or reference
sessionIdstring | nullFrontmatter originSessionId
modifiedstringFrontmatter modified, else the file's modification time
size / lineCountnumberFile size in bytes and line count
links / linkedFromstring[]Filenames this entry links to, and that link to it (markdown links and [[wikilinks]])
inIndexbooleanLinked from MEMORY.md

Example Request ​

bash
curl http://localhost:3000/api/memory

Get Memory Content ​

GET /api/memory/content?id={id}

Returns the raw markdown of one memory entry, including frontmatter.

ParameterTypeRequiredDescription
idstringYesEntry id from /api/memory
bash
curl "http://localhost:3000/api/memory/content?id=-Users-dev-code-web-app%2FMEMORY.md"
json
{
  "content": "- [Testing strategy](testing-strategy.md) — fixtures over live data\n"
}

Returns 404 with Memory not found for unknown ids.


Search Memory Content ​

GET /api/memory/search?q={query}

Returns the ids of memory entries whose content contains the query (case-insensitive).

bash
curl "http://localhost:3000/api/memory/search?q=release"
json
{
  "ids": ["-Users-dev-code-web-app/release-checklist.md"]
}

List Projects ​

GET /api/projects

Returns a list of unique project names associated with plans. Projects are extracted from Claude Code's project metadata.

Response ​

FieldTypeDescription
projectsarrayArray of unique project name strings

Example Response ​

json
{
  "projects": [
    "my-webapp",
    "api-server",
    "mobile-app",
    "shared-utils"
  ]
}

Use Cases ​

  • Filter dropdowns: Populate project filter options in the UI
  • Project overview: See which projects have associated plans
  • Grouping: Group plans by project for organization

Refresh Cache ​

POST /api/refresh

Invalidates the plan cache and reloads all plans from disk. The server normally watches for file changes automatically, but this endpoint forces an immediate refresh.

Response ​

FieldTypeDescription
successbooleanWhether the cache was refreshed successfully

Example Request ​

bash
curl -X POST http://localhost:3000/api/refresh

Example Response ​

json
{
  "success": true,
  "before": 10,
  "after": 12
}
FieldTypeDescription
successbooleanWhether the cache was refreshed successfully
beforeintegerNumber of plans before refresh
afterintegerNumber of plans after refresh

Use Cases ​

  • Manual sync: Force refresh after external file changes
  • Troubleshooting: Verify cache is up-to-date
  • Automation: Refresh cache after batch operations on plan files

Open in Editor ​

POST /api/open

Opens the specified plan or memory file in the system's default editor. This uses the operating system's default application for .md files.

Request Body ​

FieldTypeRequiredDescription
filepathstringYesfilepath of a plan from /api/plans or a memory entry from /api/memory; any other path is rejected

Example Request ​

bash
curl -X POST http://localhost:3000/api/open \
  -H "Content-Type: application/json" \
  -d '{"filepath": "/Users/dev/.claude/plans/refactor-auth-module.md"}'

Response ​

FieldTypeDescription
successbooleanWhether the file was opened successfully

Example Response ​

json
{
  "success": true
}

Error Responses ​

StatusDescription
400Invalid path (not a known plan file, or malformed body)
500Failed to open file (e.g., editor not available)

Use Cases ​

  • Quick editing: Open a plan directly from the web UI
  • Integration: Allow external tools to trigger plan editing
  • Workflow: Jump from viewing to editing without leaving the context

OpenAPI Specification ​

GET /api/openapi.json

Returns the complete OpenAPI 3.0 specification for the API. Use this for generating client libraries, API documentation, or integrating with API tools.

You can also download the specification directly: openapi.json

Example Request ​

bash
curl http://localhost:3000/api/openapi.json

Use Cases ​

  • Client generation: Generate typed API clients for various languages
  • API testing: Import into Postman, Insomnia, or other API tools
  • Documentation: Generate additional API documentation
  • Validation: Validate requests and responses against the schema

Error Handling ​

All endpoints return standard HTTP status codes:

StatusMeaning
200Success
400Bad request (invalid parameters)
404Resource not found
500Internal server error

Error responses return plain text messages:

EndpointStatusMessage
/api/plans/{filename}/content404Plan not found
/api/memory/content404Memory not found
/api/open400Invalid path
/api/open500Failed to open file

Rate Limiting ​

The API does not implement rate limiting by default, as it is designed for local use. If deploying in a shared environment, consider adding a reverse proxy with rate limiting.