CLI Reference

The Trace CLI is the engine that maps your codebase. Run it from the root of your Next.js or Node.js project to generate a visual architectural map.

Quick Start

You don't need to install Trace globally. You can run it directly using `npx`:

$ npx trace-mapper map

This command performs a deep static analysis of your project. You'll see an output summarizing the parsed endpoints, outbound requests, and data edges:

─── API Endpoints (3)
┌ Next.js App Router
GET /api/users app/api/users/route.ts
POST /api/checkout app/api/checkout/route.ts
─── Outbound HTTP Calls (2)
┌ fetch
GET https://api.stripe.com/v1/customers lib/stripe.ts
POST https://api.resend.com/emails lib/email.ts
trace.dev
12 API nodes across 8 files
Endpoints 3
Outbound 2
Data edges 7
✨ https://trace-map-api.vercel.app/s/x8k2j9

The CLI will then upload this graph and provide a temporary, anonymous link that expires in 10 minutes.

Saving Permanent Maps

To save a map permanently to your account, pass your API key. The CLI will securely cache the API key locally, so you only need to provide it once!

$ npx trace-mapper map -k your_api_key_here

Tip: You can also set the TRACE_API_KEY environment variable instead of using the -k flag.

Privacy & Team Sharing

Trace ensures your architecture maps are secure by default:

  • Anonymous Maps (No API Key): Act as temporary public links. Anyone with the URL can view the map, but it is permanently deleted after 10 minutes.
  • Saved Maps (With API Key): Are permanently saved to your account and set to Private by default. Only you can view them. Unauthorized visitors will simply see a 404 page.

How to Share Private Maps

To share a map with your colleagues, navigate to your Dashboard or the Team Hub. Click the Share option on any project card to open the Access Manager. From there you can:

  • Invite by Email: Add specific team members to grant them secure access to your private map.
  • Make Public: Toggle the map to Public, allowing anyone with the direct link to view it instantly.

CLI Options

FlagDescription
-d, --dir <path>Directory to scan (defaults to current directory).
-k, --key <key>API key for Trace. Saves locally to ~/.trace/config.json automatically.
-n, --name <name>Assign a custom name to the flow (e.g. "Billing Service").
--jsonOutput raw JSON to stdout instead of uploading (useful for piping).
--include <globs>Comma-separated extra glob patterns to include in the scan.
--exclude <globs>Comma-separated extra ignore patterns (e.g. node_modules is ignored by default).