<ahref="mailto:hello@huskies.dev"class="nav-cta">Get in touch</a>
</nav>
</header>
</div>
<divclass="shell">
<divclass="docs-layout">
<asideclass="sidebar reveal r2">
<divclass="sidebar-section">
<divclass="sidebar-heading">Getting started</div>
<nav>
<ahref="/docs/">Overview</a>
<ahref="quickstart.html">Quickstart</a>
</nav>
</div>
<divclass="sidebar-section">
<divclass="sidebar-heading">Reference</div>
<nav>
<ahref="configuration.html">Configuration</a>
<ahref="commands.html">Bot commands</a>
<ahref="cli.html"class="active">CLI</a>
</nav>
</div>
<divclass="sidebar-section">
<divclass="sidebar-heading">Guides</div>
<nav>
<ahref="pipeline.html">Pipeline stages</a>
<ahref="transports.html">Chat transports</a>
</nav>
</div>
</aside>
<mainclass="docs-main reveal r3">
<h1class="page-title">CLI Reference</h1>
<pclass="page-subtitle">Huskies ships as a single binary. Most interaction happens through the web UI or chat transports, but the CLI is used for initial setup and server control.</p>
<tr><td>--port <PORT></td><td>3000</td><td>HTTP port to listen on. Set the <code>HUSKIES_PORT</code> environment variable as an alternative.</td></tr>
<tr><td>--project <PATH></td><td>current dir</td><td>Path to the project directory. Huskies looks for <code>.huskies/</code> here.</td></tr>
<tr><td>--help</td><td>—</td><td>Print help and exit.</td></tr>
<tr><td>--version</td><td>—</td><td>Print version and exit.</td></tr>
</tbody>
</table>
<h3>Examples</h3>
<pre><code># Start on the default port
huskies
# Start on a custom port
huskies --port 3001
# Specify project directory explicitly
huskies --project /path/to/project --port 3000
# Using environment variable
HUSKIES_PORT=3002 huskies</code></pre>
<divclass="note">
<strong>Multiple instances:</strong> Each worktree or project can run its own huskies instance on a different port. Use <code>HUSKIES_PORT</code> to avoid conflicts when running several instances simultaneously.
</div>
<h2>huskies init</h2>
<p>Initialise a project directory for use with huskies. Creates the <code>.huskies/</code> directory structure, default configuration files, and <code>.mcp.json</code>.</p>
<tr><td><code>.huskies/agents.toml</code></td><td>Agent definitions for coder, QA, and mergemaster roles.</td></tr>
<tr><td><code>.huskies/work/1_backlog/</code></td><td>Pipeline stage directories (1 through 6).</td></tr>
<tr><td><code>.huskies/specs/00_CONTEXT.md</code></td><td>Placeholder project context file for the setup wizard.</td></tr>
<tr><td><code>.huskies/specs/tech/STACK.md</code></td><td>Placeholder tech stack file for the setup wizard.</td></tr>
<tr><td><code>.mcp.json</code></td><td>MCP server config so Claude Code discovers huskies' tools automatically.</td></tr>
</tbody>
</table>
<divclass="note">
<strong>Git required:</strong> The project directory must be a git repository. Run <code>git init</code> first if needed.
</div>
<h2>huskies agent</h2>
<p>Spawn a single agent process directly from the command line. This is the command the server uses internally when you run <code>start <number></code> in chat — you rarely need to invoke it manually.</p>
<p>Project nodes can push pipeline status events to the gateway in real time over a WebSocket connection. The gateway fans each event out to all connected local subscribers.</p>
<h3>Connecting</h3>
<ol>
<li>Obtain a one-time join token: <code>POST /gateway/tokens</code> → <code>{"token":"…"}</code></li>
<li>Open a WebSocket upgrade to <code>GET /gateway/events/push?token=TOKEN&project=PROJECT_NAME</code></li>
<li>The token is consumed on upgrade. The project name is attached to every event the server broadcasts downstream.</li>
</ol>
<h3>Sending events</h3>
<p>Each message must be a JSON-encoded <code>StoredEvent</code> frame:</p>
<p>The server does not send frames back. Any other frames received by the project node indicate an error or server restart — treat them as a disconnect signal.</p>
<h3>Reconnect with exponential back-off</h3>
<p>Project nodes <strong>must</strong> reconnect on any disconnect. Use the following policy to avoid thundering herds after a gateway restart:</p>
<p>Builds macOS arm64 and Linux amd64 binaries, bumps the version, tags the repo, and publishes a Gitea release with changelog and binaries attached.</p>