11---
22name : hack-cli
33description : >
4- Use the hack CLI for local dev environments (docker compose, logs, run commands) and agent integration setup.
5- Trigger when asked to start/stop services, open project URLs, inspect logs, run commands in services, manage
6- branch instances, or configure agent integrations (Cursor/Claude/Codex/MCP). Prefer CLI over MCP when shell
7- access is available.
4+ Use the hack CLI for local runtime orchestration (compose, DNS/TLS, logs, sessions, tickets) and agent setup.
5+ Trigger when asked to run/start/stop services, inspect logs, manage lifecycle/session workflows, or update
6+ agent integrations. Prefer CLI over MCP when shell access is available.
87---
98
109# hack CLI
1110
12- Use hack CLI as the primary interface for local dev.
11+ Use ` hack ` as the primary interface for local development.
12+
13+ ## Operating Rules
14+
15+ - Prefer ` hack ` over raw ` docker ` / ` docker compose ` .
16+ - Do not start/stop project services from Docker Desktop UI for ` hack ` -managed repos.
17+ - Treat ` .hack/.internal ` and ` .hack/.branch ` as hack-managed artifacts; avoid hand-editing generated files.
18+ - Use MCP only when shell access is unavailable.
19+ - Run ` hack doctor ` (and ` hack doctor --fix ` ) before manual runtime/network repair.
20+
21+ ## Config + Schema
22+
23+ - Project config: ` .hack/hack.config.json `
24+ - Global config: ` ~/.hack/hack.config.json `
25+ - Schema URL: ` https://schemas.hack/hack.config.schema.json `
26+ - Prefer CLI config edits via ` hack config get/set ` .
27+
28+ ## Hostname Routing
29+
30+ - Primary host is ` dev_host ` (default: ` <project>.hack ` ).
31+ - Subdomains use ` <sub>.<dev_host> ` (for example: ` api.myapp.hack ` ).
32+ - OAuth alias can add ` <dev_host>.<tld> ` and ` <sub>.<dev_host>.<tld> ` (default: ` gy ` ).
33+ - Only HTTP services with Caddy labels and ` hack-dev ` network attachment are routable.
34+ - Required labels: ` caddy ` , ` caddy.reverse_proxy ` , ` caddy.tls=internal ` .
35+ - Quick checks: ` hack open ` , ` hack open <sub> ` , ` hack open --json ` .
36+
37+ ## TLS + OAuth Host Rules
38+
39+ - Caddy internal PKI provides HTTPS for routed hosts; trust CA with ` hack global trust ` .
40+ - ` .hack ` is local-first and not a public suffix.
41+ - Use alias hosts like ` *.hack.gy ` when provider callback validation rejects non-public-suffix hosts.
42+ - Alias hosts are local routes unless you explicitly add remote ingress/tunnel plumbing.
43+
44+ ## Managed Files
45+
46+ - Source-of-truth files: ` .hack/docker-compose.yml ` , ` .hack/hack.config.json ` , ` .hack/hack.env.json ` .
47+ - Local-only files: ` .hack/.env ` and ` .hack/.internal/ ` (gitignored; machine-specific state).
48+ - Generated by hack: ` .hack/.internal/compose.override.yml ` , ` .hack/.internal/compose.env.override.yml ` , ` .hack/.branch/compose.<branch>.override.yml ` .
49+ - Managed via CLI: ` .hack/.internal/extra-hosts.json ` using ` hack internal extra-hosts ... ` commands.
50+ - Lifecycle runtime files: ` .hack/.internal/lifecycle/state.json ` , ` .hack/.internal/lifecycle/*.log ` .
51+
52+ ## Advanced Networking
53+
54+ - Static host mappings: set ` internal.extra_hosts ` in ` .hack/hack.config.json ` .
55+ - Dynamic mappings for local proxies/tunnels: ` hack internal extra-hosts set <hostname> <target> ` .
56+ - List/remove mappings: ` hack internal extra-hosts list ` / ` hack internal extra-hosts unset <hostname> ` .
57+ - Prefer ` host-gateway ` for host-local proxy targets when possible.
58+ - Apply changes with ` hack restart ` ; verify with ` hack doctor ` .
1359
1460## Quick Start
1561
62+ - Bootstrap project config: ` hack init `
1663- Start services: ` hack up --detach `
64+ - Alternate shorthand: ` hack up -d `
65+ - Restart services: ` hack restart `
1766- Open app: ` hack open --json `
18- - Tail logs: ` hack logs --pretty `
67+ - Tail logs (compose): ` hack logs --pretty `
68+ - Per-service logs: ` hack logs <service> `
1969- Snapshot logs: ` hack logs --json --no-follow `
70+ - Loki history/query: ` hack logs --loki --since 2h --pretty `
2071- Run commands: ` hack run <service> <cmd...> `
2172- Stop services: ` hack down `
2273
74+ ## Global Infra
75+
76+ - Install once: ` hack global install `
77+ - Start/stop/status: ` hack global up ` , ` hack global down ` , ` hack global status `
78+ - Global logs: ` hack global logs <service> --no-follow --tail 200 `
79+
80+ ## Lifecycle + Startup
81+
82+ - Put host setup in ` .hack/hack.config.json ` under ` startup ` / ` lifecycle ` .
83+ - Use lifecycle processes for long-running host tasks, not ad-hoc terminals.
84+ - Inspect via ` hack projects --details ` and ` hack logs <service-or-process> ` .
85+
2386## Branch Instances
2487
2588Use branch instances to run parallel environments:
@@ -29,28 +92,42 @@ Use branch instances to run parallel environments:
2992- ` hack logs --branch <name> `
3093- ` hack down --branch <name> `
3194
32- ## Logs
95+ ## Sessions
96+
97+ - Picker: ` hack session `
98+ - Start/attach: ` hack session start <project> `
99+ - Isolated agent session: ` hack session start <project> --new --name agent-1 `
100+ - Exec: ` hack session exec <session> "<command>" `
101+ - Stop: ` hack session stop <session> `
102+
103+ ## Tickets
33104
34- - Loki history : ` hack logs --loki --since 2h --pretty `
35- - Filter services : ` hack logs --loki --services api,web `
36- - Force compose logs : ` hack logs --compose `
105+ - Create : ` hack tickets create --title "..." --body-stdin `
106+ - List/show : ` hack tickets list ` , ` hack tickets show T-00001 `
107+ - Status/sync : ` hack tickets status T-00001 in_progress ` , ` hack tickets sync `
37108
38109## Project Targeting
39110
40111- Run from repo root when possible.
41112- Otherwise use ` --project <name> ` or ` --path <repo-root> ` .
42113- List projects: ` hack projects --json ` .
43114
44- ## Daemon (optional)
115+ ## Agent Maintenance
45116
46- - Start for faster JSON status/ps: ` hack daemon start `
47- - Check status: ` hack daemon status `
117+ - Project-level hack commands auto-check integration drift and attempt auto-sync.
118+ - Set ` HACK_SETUP_SYNC_MODE=warn ` to warn-only, or ` HACK_SETUP_SYNC_MODE=off ` to disable.
119+ - Refresh project + global integrations: ` hack setup sync --all-scopes `
120+ - Check generated integrations: ` hack setup sync --all-scopes --check `
121+ - Remove generated integrations: ` hack setup sync --all-scopes --remove `
122+ - After self-update: ` hack update ` then ` hack setup sync --all-scopes `
48123
49124## Agent Setup
50125
51126- Cursor rules: ` hack setup cursor `
52127- Claude hooks: ` hack setup claude `
53128- Codex skill: ` hack setup codex `
129+ - Tickets skill: ` hack setup tickets `
54130- Init prompt: ` hack agent init ` (use --client cursor|claude|codex to open)
55131- Init patterns: ` hack agent patterns `
56132- MCP (no shell only): ` hack setup mcp `
133+ - MCP install (explicit): ` hack mcp install --all --scope project `
0 commit comments