Skip to main content

Overview

The doctor command runs comprehensive diagnostic checks on your Paperclip installation. It validates configuration, tests connections, verifies file permissions, and can automatically repair common issues.

Syntax

Options

--config <path>

Path to config file to check. Default: ~/.paperclip/instances/default/config.json

--data-dir <path>

Paperclip data directory root.

--repair

Attempt to repair issues automatically.

--fix

Alias for --repair.

--yes / -y

Skip repair confirmation prompts. Auto-confirm all repairs.

Health Checks

Doctor runs these checks in order:

1. Config File

Validates configuration file exists and is readable. Pass:
Fail:
Can repair: No (must run onboard)

2. Deployment/Auth Mode

Verifies deployment mode and auth configuration are consistent. Valid combinations:
  • local_trusted + any exposure
  • authenticated + private or public
Pass:
Warn:
Can repair: No (configuration choice)

3. Agent JWT Secret

Checks for PAPERCLIP_AGENT_JWT_SECRET in environment or .env.local file. Pass:
Fail:
Can repair: Yes - Generates new secret and writes to .env.local

4. Secrets Adapter

Validates secrets configuration and key file. Pass:
Fail:
Can repair: Yes - Creates key file and directory

5. Storage Adapter

Verifies storage configuration and paths. Pass (local_disk):
Pass (s3):
Fail:
Can repair: Yes - Creates storage directory

6. Database

Tests database connectivity and configuration. Pass (embedded-postgres):
Pass (postgres):
Fail:
Can repair: Yes - Can create database directory for embedded mode

7. LLM Provider

Validates LLM configuration if present. Pass:
Warn:
Fail:
Can repair: No (requires valid API key)

8. Log Directory

Verifies log directory exists and is writable. Pass:
Fail:
Can repair: Yes - Creates log directory

9. Server Port

Checks if configured port is available. Pass:
Warn:
Can repair: No (requires manual port change)

Output Format

Status Icons

  • (green) - Check passed
  • ! (yellow) - Warning (non-blocking)
  • (red) - Check failed (may block startup)

Check Result

Each check shows:

Summary

At the end:
Outcomes:
  • All passed: All checks passed! (green)
  • Warnings only: All critical checks passed with some warnings. (yellow)
  • Failures: Some checks failed. Fix the issues above and re-run doctor. (red)

Auto-Repair

Interactive Repair

With --repair (no --yes):
You’ll be prompted for each repairable issue:

Non-Interactive Repair

With --repair --yes:
All repairs are applied automatically without prompts:

Repair Actions

Doctor can automatically:
  1. Generate JWT secret - Creates new secret in .env.local
  2. Create secrets key - Generates master encryption key
  3. Create directories - Makes missing log, storage, or database directories
  4. Fix permissions - Ensures directories are writable (if possible)

Examples

Basic health check

Runs all checks, reports issues, no repairs.

Check and repair

Prompts before each repair action.

Fully automated repair

Fixes everything automatically, no prompts.

Check specific config

Checks production configuration.

Pre-deployment check

Exit Codes

Doctor returns:
  • 0 - All checks passed (or only warnings)
  • 1 - One or more checks failed

Integration with Other Commands

Used by run

The run command automatically calls doctor:

After onboard

Recommended to verify setup:

Before configure

Check current state:

Troubleshooting

All checks fail with “Config file not found”

Solution: Run onboard first:

Database check fails

For embedded-postgres:
For external postgres:

Port check warns “in use”

Find what’s using the port:
Kill the process:
Or change port:

LLM provider check fails

Update API key:
Test manually:

Secrets key file check fails

Auto-create:
Manual creation:

Storage directory check fails

Auto-create:
Manual creation:

Permission errors during repair

Run with proper permissions:
Or fix ownership:

CI/CD Integration

Pre-deployment Health Check

GitHub Actions

Docker Health Check

Best Practices

Regular Health Checks

Run doctor periodically:

After Configuration Changes

Always verify after changes:

Before Production Deploy

Validate staging environment:

Monitor Exit Code

In scripts:

Next Steps

Fix configuration

Update configuration sections

Start server

Run Paperclip after repairs

Re-run setup

Go through onboarding again