Skip to main content

Overview

The run command is the primary way to start your Paperclip instance. It automatically handles onboarding (if needed), runs diagnostic checks, and starts the server. This is the command you’ll use most often in development and production.

Syntax

Options

--config <path>

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

--data-dir <path>

Paperclip data directory root. Isolates state from ~/.paperclip.

--instance <id>

Local instance ID. Useful for running multiple isolated instances. Default: default Allowed characters: Letters, numbers, _, and -

--repair

Attempt automatic repairs during doctor checks. Default: true

--no-repair

Disable automatic repairs during doctor checks.

What It Does

The run command executes a three-phase startup sequence:

1. Setup Validation

Checks for existing configuration:
  • Creates home directory if missing
  • Creates instance directory if missing
  • Checks for config file

2. Auto-Onboarding

If no config is found: Interactive terminal:
Runs paperclipai onboard automatically, then continues. Non-interactive terminal (CI/automated):
Exits with code 1.

3. Health Checks

Runs paperclipai doctor with automatic repairs:
If any checks fail and can’t be auto-repaired:
Exits with code 1.

4. Server Start

If all checks pass:
The server process takes over and outputs:
The server runs in the foreground. Press Ctrl+C to stop.

Examples

Start default instance

Starts with defaults:
  • Instance: default
  • Config: ~/.paperclip/instances/default/config.json
  • Auto-repair: enabled

Start specific instance

Uses configuration from ~/.paperclip/instances/staging/config.json.

Custom config path

Overrides default config location.

Disable auto-repair

Doctor will only report issues without attempting fixes.

Multiple instances

Run multiple instances simultaneously:
Each instance needs:
  • Unique instance ID
  • Unique port (configure in config.json)
  • Separate database (if using embedded-postgres)

Environment Variables

These environment variables affect run behavior:

PAPERCLIP_INSTANCE_ID

Sets the instance ID.

PAPERCLIP_CONFIG

Explicit config file path.

PAPERCLIP_HOME

Override home directory.

PAPERCLIP_OPEN_ON_LISTEN

Auto-open browser when server starts (set internally by onboard).

PAPERCLIP_UI_DEV_MIDDLEWARE

Enable UI development middleware (auto-detected in monorepo).

Server Modes

Development Mode

If running from the monorepo workspace:
Behavior:
  • Imports server/src/index.ts directly
  • Enables UI dev middleware
  • Supports hot reloading (with tsx/nodemon)

Production Mode

If installed globally or using published package:
Behavior:
  • Imports @paperclipai/server package
  • Serves pre-built UI assets
  • Production-optimized

Server Output

Successful Start

Request Logs

HTTP requests are logged:

Database Migrations

On first start or schema changes:

Stopping the Server

Graceful Shutdown

Press Ctrl+C to trigger graceful shutdown:

Force Kill

If graceful shutdown hangs, press Ctrl+C again:

Troubleshooting

Port already in use

Solutions:
  1. Check what’s using the port:
  2. Kill the conflicting process:
  3. Change the port:

Database connection failed

For embedded-postgres:
  1. Check logs:
  2. Verify port is available:
  3. Reset database:
For external postgres:
  1. Test connection manually:
  2. Verify DATABASE_URL:
  3. Update connection:

Server starts but UI not accessible

Check server config:
Verify UI is enabled: In config.json:
Try different host: If bound to 127.0.0.1, only accessible locally. For network access:
Security: Only bind to 0.0.0.0 in trusted networks or with proper authentication.

Module not found error

Solutions:
  1. Reinstall dependencies:
  2. Verify installation:
  3. Use npx instead:

Doctor fails with blocking issues

Run doctor separately to see details:
Fix issues manually and retry:

Production Deployment

For production deployments:

Using systemd

Create /etc/systemd/system/paperclip.service:
Enable and start:

Using Docker

Create Dockerfile:
Build and run:

Environment Variables for Production

Set these in production:
Generate export block:

Next Steps

Verify health

Run diagnostic checks on your running instance

Update config

Modify configuration without stopping

Production setup

Deploy to production environments