NAME
d2 - thin command switchboard for Developer Dashboard
SYNOPSIS
d2 help
d2 init
d2 doctor [--fix]
d2 ps1 [--jobs N] [--cwd PATH] [--mode compact|extended] [--color]
d2 paths [-o json|table]
d2 files
d2 files [-o json|table]
d2 path list [-o json|table]
d2 path resolve <name>
d2 path add <name> <path> [-o json|table]
d2 path del <name> [-o json|table]
d2 path rm <name>
d2 path locate <term...>
d2 path project-root
d2 file list [-o json|table]
d2 file resolve <name>
d2 file add <name> <path> [-o json|table]
d2 file del <name> [-o json|table]
d2 file locate <term...>
d2 of [--print] [--line N] [--editor CMD] <file|scope> [pattern...]
d2 open-file [--print] [--line N] [--editor CMD] <file|scope> [pattern...]
d2 workspace <workspace-ref> [-c] [-d|--docker]
d2 jq [path] [file]
d2 yq [path] [file]
d2 tomq [path] [file]
d2 propq [path] [file]
d2 iniq [path] [file]
d2 csvq [path] [file]
d2 xmlq [path] [file]
d2 encode < input.txt
d2 decode < token.txt
d2 indicator set <name> <label> <icon> <status>
d2 indicator list
d2 indicator refresh-core [cwd]
d2 collector write-result <name> <exit_code>
d2 collector status <name>
d2 collector list
d2 collector job <name>
d2 collector output <name>
d2 collector inspect <name>
d2 collector log [name]
d2 collector run <name>
d2 collector start <name>
d2 collector stop <name>
d2 collector restart <name>
d2 housekeeper
d2 skills install [-b branch] <git-url-or-local-dir>
d2 skills enable <repo-name>
d2 skills disable <repo-name>
d2 skills uninstall <repo-name>
d2 skills update <repo-name>
d2 skills list
d2 skills usage <repo-name> [-o json|table]
d2 which [--edit] <cmd>|<skill>.<cmd>|<skill1>.<skill2>...<cmd>
d2 config init
d2 config show
d2 api [ls] [--key <name>] [-o json|table]
d2 api add --key <name> [--secret <raw>|--maybe-secret <raw>] [--route /ajax/...]... [-o json|table]
d2 api rm --key <name> [--route /ajax/...] [-o json|table]
d2 auth add-user <username> <password>
d2 auth list-users
d2 auth remove-user <username>
d2 page new [id] [title]
d2 page save <id>
d2 page list
d2 page show <id>
d2 page encode [id]
d2 page decode [token]
d2 page urls <id>
d2 page render [id|file]
d2 page source <id|token>
d2 action run <page_id> <action_id>
d2 docker compose [--addon NAME] [--mode NAME] [--service NAME] [--project DIR] [--dry-run] <compose-args...>
d2 docker list [--enabled|--disabled]
d2 docker enable <service> [service...]
d2 docker disable <service> [service...]
d2 docker development {enable|disable} <service> [service...]
d2 serve [logs [-t] [-f] [--tail N|--tail=N] [-n N]|workers <N>] [--host HOST] [--port PORT] [--workers N] [--foreground] [--no-editor|--no-endit] [--no-indicators|--no-indicator]
d2 stop
d2 restart [--host HOST] [--port PORT] [--workers N]
d2 shell [bash|zsh|sh|ps|powershell|pwsh]
d2 upgrade [--dry-run]
d2 version
d2 <custom-subcommand> [args...]
DESCRIPTION
The public d2 entrypoint is intentionally kept thin.
It only:
bootstraps the repo lib path when running from a checkout
runs the main gate: every executable file under a layer's hooks/ directory, once per invocation, before the command is even resolved
runs layered per-command hooks across
DD-OOP-LAYERSstages dashboard-managed built-in helpers under ~/.developer-dashboard/cli/dd/
resolves the effective command from the deepest child layer back to home
execs the resolved helper or custom command
The real built-in command implementations live outside this entrypoint, either in private staged helper scripts under share/private-cli/ or in reusable Perl modules loaded by those helpers.
Built-in help requests are resolved through the shared CLI help catalog after the established main and per-command hook gates have run, but before a helper body is dispatched. Root commands and actions accept --help, -h, or a trailing help; the global form is d2 help <command> [action...]. Bare d2 help, d2 --help, and d2 -h print a concise index of public built-in commands instead of this full manual. Shell completion calls the same catalog-backed d2 complete command for public command, action, and option candidates.
The main gate
Before any command is resolved - including d2 with no command, help, version, which and a command that does not exist - the switchboard runs the main gate: every executable regular file directly under a runtime layer's hooks/ directory, in sorted filename order. Files that are not executable, subdirectories and a file named run are skipped, exactly as the per-command hook chain skips them. The layers run deepest first and home last, so ./.developer-dashboard/hooks/ speaks before ~/.developer-dashboard/hooks/, and every layer between the working directory and home contributes its own hooks.
Each hook receives the full command line, command word first (for d2 version --json that is version --json; with no command the hook gets no arguments). Its stdout streams to the terminal ahead of the command's output, and its captured stdout, stderr and exit code are recorded in RESULT and LAST_RESULT for the hooks after it and for the command itself. A hook that prints the literal marker [[STOP]] on stderr stops the invocation: the remaining hooks are skipped, the command does not run, and d2 exits 1 with the hook's stderr visible. That differs on purpose from a per-command hook's [[STOP]], which only ends the remaining hook chain and still runs the command.
A hook that itself runs d2 does not re-fire the gate: the hooks run with DEVELOPER_DASHBOARD_MAIN_GATE set, and a nested switchboard that inherits it skips the gate. There is only one entrypoint, so the gate fires exactly once. With no hooks/ directory on any layer, nothing changes: no output, no stderr, the same exit status as before the gate existed.
PURPOSE
This is the one public executable users invoke. It bootstraps PERL5LIB when running from a checkout, runs layered command hooks across DD-OOP-LAYERS, stages dashboard-managed built-in helpers under ~/.developer-dashboard/cli/dd/, and then execs the final helper or custom command instead of owning the heavy implementation itself. The switchboard also leaves hook-process modules unloaded on commands that do not run executable hooks, and loads usage-rendering support only on usage-error paths.
WHY IT EXISTS
It exists to keep the command surface stable while the implementation stays decomposed. The repo rule is that d2 remains a switchboard, so this file owns dispatch, helper staging, and hook execution rather than data queries, SQL workspaces, page rendering, or other subsystem logic.
WHEN TO USE
Use this file when you are changing top-level command discovery, the order of command hooks, how built-in helpers are staged, or the deepest-to-home lookup rules for layered custom commands.
HOW TO USE
Users run d2 <subcommand>. This script resolves whether that subcommand is a dashboard-managed helper or a user-layer command, primes the RESULT and LAST_RESULT hook state, honors the explicit [[STOP]] stderr marker when one hook wants to stop the remaining hook chain, and then hands off with exec. If behavior belongs to a subsystem, move it into a module or private helper instead of expanding this file.
WHAT USES IT
It is used directly by end users, shell bootstraps, private staged helpers that re-enter the public command path, tests that execute d2 commands, and release/integration smoke runs that verify the installed command surface.
EXAMPLES
Example 1:
d2 paths
Exercise thin command dispatch through one lightweight built-in helper.
Example 2:
d2 page source index
Use the public entrypoint to reach a heavier staged helper without embedding that implementation here.
Example 3:
d2 serve --foreground
Run the public command through its server bootstrap path while keeping logs in the foreground.
Example 4:
d2 which nest.level1.level2.here
d2 which --edit jq
Inspect the exact resolved command file and hook chain without running the command body.
Example 5:
d2 workspace -c project --docker
Use the public switchboard to reach the staged workspace helper; that helper executes Docker Compose from the registered alias directory and starts the interactive tmux workspace inside its configured workspace service.
Example 6:
mkdir -p ~/.developer-dashboard/cli/update.d
printf '#!/bin/sh\necho first\n' > ~/.developer-dashboard/cli/update.d/00-first
printf '#!/bin/sh\necho stop >&2; echo "[[STOP]]" >&2\n' > ~/.developer-dashboard/cli/update.d/01-stop
chmod +x ~/.developer-dashboard/cli/update.d/00-first ~/.developer-dashboard/cli/update.d/01-stop
d2 update
Exercise the explicit stop-marker hook path, where one hook ends the remaining hook chain but control still returns to the main command.
Example 7:
mkdir -p ~/.developer-dashboard/hooks
printf '#!/bin/sh\n[ -n "$DD_TICKET" ] && exit 0\necho "set DD_TICKET first" >&2\necho "[[STOP]]" >&2\n' > ~/.developer-dashboard/hooks/10-ticket
chmod +x ~/.developer-dashboard/hooks/10-ticket
d2 version # refused, exit 1, stderr says why
DD_TICKET=DD-1 d2 version # gate passes, version prints
Exercise the main gate: one hook under hooks/ runs before every command, through both entrypoints, and its [[STOP]] refuses the command entirely.
Example 8:
prove -lv t/30-dashboard-loader.t
Rerun the loader contract test after changing how this public switchboard stages or dispatches helpers.