@invariant.guru/cli 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +465 -111
- package/dist/main.js +533 -527
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,112 +1,277 @@
|
|
|
1
1
|
# Invariant CLI
|
|
2
2
|
|
|
3
|
-
A package manager for
|
|
3
|
+
A package manager for AI coding-agent context. Install, compose, and sync reusable agents, skills, commands, rules, contexts, and instructions. Every item is stored **once** in `.agents/` — the [Agent Skills](https://agentskills.io) standard most harnesses read natively — and each CLI target gets a view of it rather than its own copy.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Node.js `>= 24`
|
|
8
|
+
- `git` on `PATH` (used for GitHub package sources)
|
|
4
9
|
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
7
12
|
```bash
|
|
8
|
-
|
|
13
|
+
# npm
|
|
14
|
+
npm install -g @invariant.guru/cli
|
|
15
|
+
|
|
16
|
+
# yarn
|
|
17
|
+
yarn global add @invariant.guru/cli
|
|
18
|
+
|
|
19
|
+
# pnpm
|
|
20
|
+
pnpm add -g @invariant.guru/cli
|
|
9
21
|
```
|
|
10
22
|
|
|
11
|
-
|
|
23
|
+
Verify and keep it current:
|
|
12
24
|
|
|
13
25
|
```bash
|
|
14
|
-
|
|
15
|
-
invariant
|
|
26
|
+
invariant version
|
|
27
|
+
invariant update --check
|
|
28
|
+
invariant update
|
|
29
|
+
```
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
invariant install everything-claude-code
|
|
31
|
+
## Getting Started
|
|
19
32
|
|
|
20
|
-
|
|
21
|
-
invariant add agent:everything-claude-code/planner
|
|
33
|
+
The core loop is **init → install → add → sync**, with `plan` on top when you start a task.
|
|
22
34
|
|
|
23
|
-
|
|
24
|
-
|
|
35
|
+
### 1. `invariant init` — set up the project
|
|
36
|
+
|
|
37
|
+
Run once at the repository root. Creates `invariant.json` (the manifest) and `.invariant/` (cache, contexts, instructions, sessions, codegraph).
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
invariant init # defaults to the `claude` target
|
|
41
|
+
invariant init claude cursor # multiple targets
|
|
42
|
+
invariant init --name my-project
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Supported targets: `claude`, `codex`, `cursor`, `aider`, `copilot`.
|
|
46
|
+
|
|
47
|
+
### 2. `invariant install` — pull a package
|
|
48
|
+
|
|
49
|
+
Packages come from the registry or straight from GitHub. Installing caches the package **and** activates its items.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# From GitHub (owner/repo, optional #ref)
|
|
53
|
+
invariant install github:invariant-guru/inv-nest-clean-architecture
|
|
54
|
+
|
|
55
|
+
# Pin a branch or tag
|
|
56
|
+
invariant install github:invariant-guru/inv-nest-clean-architecture#main
|
|
57
|
+
|
|
58
|
+
# From the registry (same package, published name)
|
|
59
|
+
invariant install nest-clean-architecture
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
This writes the package into `invariant.json`:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"packages": {
|
|
67
|
+
"nest-clean-architecture": {
|
|
68
|
+
"name": "nest-clean-architecture",
|
|
69
|
+
"version": "1.0.0",
|
|
70
|
+
"source": "github",
|
|
71
|
+
"sourceUrl": "github:invariant-guru/inv-nest-clean-architecture"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 3. `invariant add` — pick what's active
|
|
78
|
+
|
|
79
|
+
`install` already activates everything. Use `add` to curate: a whole package, one item type, or a single item.
|
|
80
|
+
|
|
81
|
+
**Add the whole module** — every agent, skill, command, rule, context, and instruction the package ships:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
invariant add nest-clean-architecture
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Adding all items from nest-clean-architecture...
|
|
89
|
+
✓ Added items from nest-clean-architecture
|
|
90
|
+
agents:
|
|
91
|
+
- clean-architect
|
|
92
|
+
skills:
|
|
93
|
+
- implement-aggregate-root
|
|
94
|
+
- implement-command
|
|
95
|
+
- implement-query
|
|
96
|
+
- ...
|
|
97
|
+
rules:
|
|
98
|
+
- aggregate-root
|
|
99
|
+
- command
|
|
100
|
+
- ...
|
|
101
|
+
instructions:
|
|
102
|
+
- nest-clean-architecture
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
**Add one type** — e.g. only the skills, or only the rules:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
invariant add skills:nest-clean-architecture
|
|
109
|
+
invariant add rules:nest-clean-architecture
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Add single items** — one target per item, mixed types allowed:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
invariant add agent:nest-clean-architecture/clean-architect
|
|
116
|
+
invariant add skill:nest-clean-architecture/implement-command \
|
|
117
|
+
rule:nest-clean-architecture/command
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Check what landed with `invariant inspect nest-clean-architecture`, or use `invariant add-interactive` for a checkbox tree of every installed item.
|
|
121
|
+
|
|
122
|
+
### 4. `invariant sync` — reconcile and write the files
|
|
123
|
+
|
|
124
|
+
`sync` brings the whole tree back in line with `invariant.json`: it rebuilds
|
|
125
|
+
canonical items that went missing, materializes every active item for every
|
|
126
|
+
configured target, prunes what is no longer active, and regenerates the context
|
|
127
|
+
files (`CLAUDE.md`, `AGENTS.md`, …).
|
|
128
|
+
|
|
129
|
+
Add a target to `invariant.json`, run `sync`, and that target is set up — no need
|
|
130
|
+
to re-run `add`.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
invariant sync
|
|
134
|
+
invariant sync --target claude
|
|
135
|
+
invariant sync --check # CI gate: exits 1 when the tree is stale
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
`add`, `install`, and `add-interactive` all accept `-s, --sync` to do this in one shot:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
invariant install github:invariant-guru/inv-nest-clean-architecture --sync
|
|
25
142
|
```
|
|
26
143
|
|
|
144
|
+
### 5. `invariant plan` — start a task
|
|
145
|
+
|
|
146
|
+
Composes a session file under `.invariant/sessions/` containing your prompt plus the active instructions (and optionally a context), then prints the one-liner to paste into your agent.
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
invariant plan "implement the cargo booking command"
|
|
150
|
+
invariant plan "implement the cargo booking command" --context nest-clean-architecture/dev
|
|
151
|
+
invariant plan "implement the cargo booking command" --full
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
When the session is done, stamp it:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
invariant plan:complete <session-id> --summary "Booking command + tests"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Full walkthrough
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
invariant init claude
|
|
164
|
+
invariant install github:invariant-guru/inv-nest-clean-architecture
|
|
165
|
+
invariant add nest-clean-architecture # activate the whole module
|
|
166
|
+
invariant sync
|
|
167
|
+
invariant plan "add the cargo booking command"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
27
172
|
## Commands
|
|
28
173
|
|
|
29
|
-
### `invariant init`
|
|
174
|
+
### `invariant init [targets...]`
|
|
30
175
|
|
|
31
|
-
Initialize
|
|
176
|
+
Initialize a new invariant project with the given target CLI(s). Defaults to `claude`.
|
|
32
177
|
|
|
33
178
|
```bash
|
|
34
179
|
invariant init
|
|
180
|
+
invariant init claude cursor
|
|
35
181
|
invariant init --name my-project
|
|
182
|
+
invariant init --hybrid
|
|
36
183
|
```
|
|
37
184
|
|
|
38
|
-
|
|
185
|
+
| Option | Description |
|
|
186
|
+
|--------|-------------|
|
|
187
|
+
| `-n, --name <name>` | Project name (defaults to directory name) |
|
|
188
|
+
| `--hybrid` | Initialize as hybrid mode — project *and* package in one directory |
|
|
189
|
+
| `--copy` | Copy items into each target folder instead of linking them to `.agents/` |
|
|
190
|
+
| `--canonical-dir <dir>` | Canonical store location (default `.agents`) |
|
|
191
|
+
|
|
192
|
+
### `invariant install [packages...]`
|
|
39
193
|
|
|
40
|
-
Install packages from the registry
|
|
194
|
+
Install packages from the registry or GitHub and activate their items. If the package already has curated `active` entries in `invariant.json`, exactly those are restored; otherwise all items are added.
|
|
41
195
|
|
|
42
196
|
```bash
|
|
43
|
-
invariant install
|
|
197
|
+
invariant install github:invariant-guru/inv-nest-clean-architecture
|
|
198
|
+
invariant install github:invariant-guru/inv-nest-clean-architecture#v1.2.0
|
|
199
|
+
invariant install nest-clean-architecture
|
|
200
|
+
invariant install nest-clean-architecture@1.0.0
|
|
44
201
|
|
|
45
|
-
#
|
|
202
|
+
# Reinstall every package declared in invariant.json
|
|
46
203
|
invariant install
|
|
47
204
|
|
|
48
|
-
#
|
|
49
|
-
invariant install
|
|
50
|
-
|
|
51
|
-
# Run `invariant sync` automatically afterwards
|
|
52
|
-
invariant install everything-claude-code --sync
|
|
205
|
+
# Cache only, activate nothing
|
|
206
|
+
invariant install nest-clean-architecture --no-add
|
|
53
207
|
```
|
|
54
208
|
|
|
209
|
+
Source syntax:
|
|
210
|
+
|
|
211
|
+
| Form | Meaning |
|
|
212
|
+
|------|---------|
|
|
213
|
+
| `name` | Registry package, latest version |
|
|
214
|
+
| `name@version` | Registry package, pinned version |
|
|
215
|
+
| `github:owner/repo` | GitHub repo, default branch |
|
|
216
|
+
| `github:owner/repo#ref` | GitHub repo at a branch, tag, or commit |
|
|
217
|
+
|
|
55
218
|
| Option | Description |
|
|
56
219
|
|--------|-------------|
|
|
57
220
|
| `--no-add` | Only cache the package, do not activate its items |
|
|
58
221
|
| `-s, --sync` | Run `invariant sync` after installing |
|
|
59
222
|
|
|
60
|
-
### `invariant add
|
|
223
|
+
### `invariant add [targets...]`
|
|
61
224
|
|
|
62
|
-
Activate items from
|
|
225
|
+
Activate items from cached packages. Accepts one or more targets.
|
|
63
226
|
|
|
64
|
-
|
|
65
|
-
# Add all items from a package
|
|
66
|
-
invariant add everything-claude-code
|
|
67
|
-
|
|
68
|
-
# Add a specific agent
|
|
69
|
-
invariant add agent:everything-claude-code/planner
|
|
227
|
+
Target formats:
|
|
70
228
|
|
|
71
|
-
|
|
72
|
-
|
|
229
|
+
| Form | Meaning |
|
|
230
|
+
|------|---------|
|
|
231
|
+
| `<package>` | All items from the package |
|
|
232
|
+
| `<type>:<package>` | All items of that type |
|
|
233
|
+
| `<type>:<package>/<item>` | One specific item |
|
|
234
|
+
| `<package>/<item>` | One item, searching every type |
|
|
73
235
|
|
|
74
|
-
|
|
75
|
-
invariant add agent:pkg-a/planner skill:pkg-b/tdd
|
|
236
|
+
Types (singular or plural): `agent`, `skill`, `command`, `rule`, `context`, `instruction`.
|
|
76
237
|
|
|
77
|
-
|
|
78
|
-
invariant add
|
|
238
|
+
```bash
|
|
239
|
+
invariant add nest-clean-architecture
|
|
240
|
+
invariant add agent:nest-clean-architecture/clean-architect
|
|
241
|
+
invariant add skill:nest-clean-architecture/implement-query \
|
|
242
|
+
skill:nest-clean-architecture/implement-repository
|
|
243
|
+
invariant add rules:nest-clean-architecture # every rule
|
|
244
|
+
invariant add agent:nest-clean-architecture/clean-architect skill:skills/skill-creator --sync
|
|
79
245
|
```
|
|
80
246
|
|
|
247
|
+
Run with no arguments to print usage.
|
|
248
|
+
|
|
81
249
|
| Option | Description |
|
|
82
250
|
|--------|-------------|
|
|
83
251
|
| `-s, --sync` | Run `invariant sync` after adding |
|
|
84
252
|
|
|
85
253
|
### `invariant add-interactive`
|
|
86
254
|
|
|
87
|
-
Interactively select/unselect what's active — like `yarn upgrade-interactive`. Checked rows reflect
|
|
255
|
+
Interactively select/unselect what's active — like `yarn upgrade-interactive`. Checked rows reflect current activation state; checking adds, unchecking removes.
|
|
88
256
|
|
|
89
|
-
|
|
257
|
+
Default view is a **hierarchical tree**: package → item type → item. Toggling a package or type row **cascades** to its items. Category rows show a `selected/total` count and a tri-state glyph — `◉` all, `◐` some, `◯` none:
|
|
90
258
|
|
|
91
259
|
```
|
|
92
|
-
◐ nest-clean-architecture@1.0.0
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
260
|
+
◐ nest-clean-architecture@1.0.0 1/3
|
|
261
|
+
│
|
|
262
|
+
├─ ◯ agents 0/1
|
|
263
|
+
│ └─ ◯ clean-architect
|
|
264
|
+
│
|
|
265
|
+
└─ ◐ skills 1/2
|
|
266
|
+
├─ ◉ implement-command
|
|
267
|
+
└─ ◯ implement-query
|
|
98
268
|
```
|
|
99
269
|
|
|
100
|
-
Keys: `↑↓` move · `space` toggle (cascades on a package/type row) · `a` all · `i` invert · `enter` confirm.
|
|
270
|
+
Keys: `↑↓` move · `space` toggle (cascades on a package/type row) · `a` toggle all · `i` invert · `enter` confirm.
|
|
101
271
|
|
|
102
272
|
```bash
|
|
103
|
-
#
|
|
104
|
-
invariant add-interactive
|
|
105
|
-
|
|
106
|
-
# Coarse selection: one checkbox per whole package
|
|
107
|
-
invariant add-interactive --packages
|
|
108
|
-
|
|
109
|
-
# Apply changes and sync immediately
|
|
273
|
+
invariant add-interactive # item-level tree (default)
|
|
274
|
+
invariant add-interactive --packages # one checkbox per whole package
|
|
110
275
|
invariant add-interactive --sync
|
|
111
276
|
```
|
|
112
277
|
|
|
@@ -118,124 +283,313 @@ In `--packages` mode an already-active package left checked is untouched, so a c
|
|
|
118
283
|
| `-s, --sync` | Run `invariant sync` after applying changes |
|
|
119
284
|
| `-t, --target <target>` | With `--sync`, sync only to a specific target |
|
|
120
285
|
|
|
121
|
-
### `invariant remove
|
|
286
|
+
### `invariant remove [targets...]`
|
|
122
287
|
|
|
123
|
-
|
|
288
|
+
Deactivate items (inverse of `add`). The package stays in cache. Same target formats as `add`.
|
|
124
289
|
|
|
125
290
|
```bash
|
|
126
|
-
|
|
127
|
-
invariant remove
|
|
291
|
+
invariant remove nest-clean-architecture
|
|
292
|
+
invariant remove agent:nest-clean-architecture/clean-architect
|
|
293
|
+
invariant remove rules:nest-clean-architecture
|
|
294
|
+
invariant remove skill:nest-clean-architecture/implement-saga \
|
|
295
|
+
skill:nest-clean-architecture/implement-saga-test
|
|
296
|
+
```
|
|
128
297
|
|
|
129
|
-
|
|
130
|
-
invariant remove agent:everything-claude-code/planner
|
|
298
|
+
### `invariant uninstall <packages...>`
|
|
131
299
|
|
|
132
|
-
|
|
133
|
-
|
|
300
|
+
Completely remove packages: deletes all added items, drops the cache, and removes them from `invariant.json`.
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
invariant uninstall nest-clean-architecture
|
|
304
|
+
invariant uninstall nest-clean-architecture skills
|
|
134
305
|
```
|
|
135
306
|
|
|
136
|
-
### `invariant
|
|
307
|
+
### `invariant sync`
|
|
137
308
|
|
|
138
|
-
|
|
309
|
+
Sync active instructions, contexts, and items to every configured CLI target (or just one).
|
|
139
310
|
|
|
140
311
|
```bash
|
|
141
|
-
invariant
|
|
312
|
+
invariant sync
|
|
313
|
+
invariant sync --target cursor
|
|
142
314
|
```
|
|
143
315
|
|
|
316
|
+
| Option | Description |
|
|
317
|
+
|--------|-------------|
|
|
318
|
+
| `-t, --target <target>` | Sync only to a specific target (`claude`, `codex`, `cursor`, `aider`, `copilot`). Skips pruning — the other targets are out of scope |
|
|
319
|
+
| `--check` | Report drift without writing anything; exits `1` when out of sync |
|
|
320
|
+
| `--force` | Replace target files that were hand-edited away from the canonical item |
|
|
321
|
+
|
|
144
322
|
### `invariant inspect [package]`
|
|
145
323
|
|
|
146
324
|
Show package contents with active items highlighted.
|
|
147
325
|
|
|
148
|
-
**Without a target** —
|
|
326
|
+
**Without a target** — only active items across all installed packages:
|
|
149
327
|
|
|
150
328
|
```bash
|
|
151
329
|
invariant inspect
|
|
152
330
|
```
|
|
153
331
|
|
|
154
332
|
```
|
|
155
|
-
|
|
333
|
+
nest-clean-architecture@1.0.0
|
|
156
334
|
────────────────────────────────────────
|
|
157
335
|
agents/
|
|
158
|
-
✓
|
|
336
|
+
✓ clean-architect
|
|
159
337
|
skills/
|
|
160
|
-
✓
|
|
338
|
+
✓ implement-command
|
|
161
339
|
```
|
|
162
340
|
|
|
163
|
-
**With `--details`** —
|
|
341
|
+
**With `--details`** — all items, active and inactive, across all packages. **With a package name** — always all items for that package.
|
|
164
342
|
|
|
165
343
|
```bash
|
|
166
344
|
invariant inspect --details
|
|
345
|
+
invariant inspect nest-clean-architecture
|
|
167
346
|
```
|
|
168
347
|
|
|
348
|
+
| Option | Description |
|
|
349
|
+
|--------|-------------|
|
|
350
|
+
| `-d, --details` | Show all items including inactive ones |
|
|
351
|
+
|
|
352
|
+
### `invariant list`
|
|
353
|
+
|
|
354
|
+
List installed or available packages.
|
|
355
|
+
|
|
356
|
+
```bash
|
|
357
|
+
invariant list # installed packages
|
|
358
|
+
invariant list --remote # available packages from the registry
|
|
359
|
+
invariant list --active # only packages with active items
|
|
169
360
|
```
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
361
|
+
|
|
362
|
+
| Option | Description |
|
|
363
|
+
|--------|-------------|
|
|
364
|
+
| `-r, --remote` | List available packages from the registry |
|
|
365
|
+
| `-a, --active` | List only active packages |
|
|
366
|
+
|
|
367
|
+
### `invariant plan <prompt>`
|
|
368
|
+
|
|
369
|
+
Generate a session file in `.invariant/sessions/` with the task instructions plus active context.
|
|
370
|
+
|
|
371
|
+
```bash
|
|
372
|
+
invariant plan "implement user authentication"
|
|
373
|
+
invariant plan "implement user authentication" --full
|
|
374
|
+
invariant plan "implement user authentication" --context nest-clean-architecture/dev
|
|
182
375
|
```
|
|
183
376
|
|
|
184
|
-
|
|
377
|
+
| Option | Description |
|
|
378
|
+
|--------|-------------|
|
|
379
|
+
| `-c, --context <context>` | Context to include (format: `package/context-name`) |
|
|
380
|
+
| `-f, --full` | Inline full content from active packages instead of referencing the context file |
|
|
381
|
+
|
|
382
|
+
### `invariant plan:complete <session>`
|
|
383
|
+
|
|
384
|
+
Stamp a completion header at the top of a finished session file.
|
|
185
385
|
|
|
186
386
|
```bash
|
|
187
|
-
invariant
|
|
387
|
+
invariant plan:complete session-uuid --summary "Auth command + e2e tests"
|
|
388
|
+
invariant plan:complete session-uuid -n "Follow-up: rate limiting" -d 2026-08-19
|
|
188
389
|
```
|
|
189
390
|
|
|
190
|
-
|
|
|
191
|
-
|
|
192
|
-
| `-
|
|
391
|
+
| Option | Description |
|
|
392
|
+
|--------|-------------|
|
|
393
|
+
| `-s, --summary <summary>` | Short resume of what the session accomplished |
|
|
394
|
+
| `-n, --note <note>` | Extra note line (repeatable) |
|
|
395
|
+
| `-d, --date <date>` | Completion date (`YYYY-MM-DD`), defaults to today |
|
|
193
396
|
|
|
194
|
-
### `invariant
|
|
397
|
+
### `invariant scan`
|
|
195
398
|
|
|
196
|
-
|
|
399
|
+
Scan the codebase with embedded tree-sitter grammars and write a CodeGraph to `.invariant/codegraph/` — a structured inventory of files, languages, and top-level symbols for LLM navigation.
|
|
197
400
|
|
|
198
401
|
```bash
|
|
199
|
-
invariant
|
|
200
|
-
invariant
|
|
201
|
-
invariant
|
|
402
|
+
invariant scan
|
|
403
|
+
invariant scan --scope apps/cli src/core/auth
|
|
404
|
+
invariant scan --include "src/**/*.ts" --exclude "**/*.spec.ts"
|
|
405
|
+
invariant scan --max-files 2000
|
|
202
406
|
```
|
|
203
407
|
|
|
204
|
-
|
|
408
|
+
| Option | Description |
|
|
409
|
+
|--------|-------------|
|
|
410
|
+
| `-i, --include <globs...>` | Include globs (default: `**/*`) |
|
|
411
|
+
| `-e, --exclude <globs...>` | Extra exclude globs (on top of sensible defaults) |
|
|
412
|
+
| `-s, --scope <scopes...>` | Scope the scan to specific paths |
|
|
413
|
+
| `--max-files <count>` | Cap total scanned files (default: 5000) |
|
|
414
|
+
| `--max-size <bytes>` | Skip files larger than this (default: 1 MB) |
|
|
205
415
|
|
|
206
|
-
|
|
416
|
+
Supported languages: TypeScript, JavaScript, Python, Go, Rust, JSON, Markdown, HTML, CSS.
|
|
417
|
+
|
|
418
|
+
### `invariant package <subcommand>`
|
|
419
|
+
|
|
420
|
+
Package authoring — for repositories that *are* an invariant package.
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
invariant package create --name my-pkg --version 1.0.0 --author "Me"
|
|
424
|
+
invariant package refresh
|
|
425
|
+
invariant package validate
|
|
426
|
+
invariant package publish
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
| Subcommand | Description |
|
|
430
|
+
|------------|-------------|
|
|
431
|
+
| `create` | Scan the current folder and add package metadata to `invariant.json` |
|
|
432
|
+
| `refresh` | Rescan items on disk and update `invariant.json` |
|
|
433
|
+
| `validate` | Validate the items declared in `invariant.json` against disk |
|
|
434
|
+
| `publish` | Validate, bundle, and publish the package to the registry |
|
|
435
|
+
|
|
436
|
+
`package create` options: `-n, --name`, `--version`, `-d, --description`, `-a, --author`, `-l, --license`, `-r, --repository`.
|
|
437
|
+
|
|
438
|
+
### `invariant proxy <subcommand>`
|
|
439
|
+
|
|
440
|
+
Shared local LLM proxy daemon. Routes a repo's agent traffic through a local proxy by writing a managed env block (`ANTHROPIC_BASE_URL`) into `.claude/settings.json`.
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
invariant proxy start
|
|
444
|
+
invariant proxy status
|
|
445
|
+
invariant proxy status --json
|
|
446
|
+
invariant proxy on # route the current repo (or `on <dir>`)
|
|
447
|
+
invariant proxy off # revert the managed env block
|
|
448
|
+
invariant proxy stop
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
| Subcommand | Description |
|
|
452
|
+
|------------|-------------|
|
|
453
|
+
| `start` | Start the shared proxy daemon |
|
|
454
|
+
| `stop` | Stop the daemon (token is preserved) |
|
|
455
|
+
| `status` | Daemon status, routes, and per-repo activations (`--json`) |
|
|
456
|
+
| `on [dir]` | Route a repo through the proxy |
|
|
457
|
+
| `off [dir]` | Revert the managed env block (daemon keeps running) |
|
|
458
|
+
|
|
459
|
+
Agents read `ANTHROPIC_BASE_URL` once at launch — restart running sessions after `proxy on`.
|
|
460
|
+
|
|
461
|
+
### `invariant claude [args...]`
|
|
462
|
+
|
|
463
|
+
Launch Claude Code through the proxy, auto-starting the daemon. All arguments pass through untouched.
|
|
207
464
|
|
|
208
465
|
```bash
|
|
209
466
|
invariant claude
|
|
467
|
+
invariant claude -- --resume
|
|
210
468
|
```
|
|
211
469
|
|
|
212
|
-
### `invariant
|
|
470
|
+
### `invariant stats [subcommand]`
|
|
213
471
|
|
|
214
|
-
|
|
472
|
+
Inspect Claude Code token usage and cost.
|
|
215
473
|
|
|
216
474
|
```bash
|
|
217
|
-
invariant
|
|
218
|
-
invariant
|
|
219
|
-
invariant
|
|
475
|
+
invariant stats
|
|
476
|
+
invariant stats --live
|
|
477
|
+
invariant stats --since 7d --format table
|
|
478
|
+
invariant stats cost
|
|
479
|
+
invariant stats models
|
|
480
|
+
invariant stats sessions
|
|
481
|
+
invariant stats projects
|
|
220
482
|
```
|
|
221
483
|
|
|
222
|
-
|
|
484
|
+
| Subcommand | Description |
|
|
485
|
+
|------------|-------------|
|
|
486
|
+
| `cost` | Cost drill-down with cache savings |
|
|
487
|
+
| `models` | Per-model token and cost aggregate |
|
|
488
|
+
| `sessions` | Per-session breakdown (sorted by cost) |
|
|
489
|
+
| `projects` | Per-project aggregate (implies `--all-projects`) |
|
|
490
|
+
|
|
491
|
+
| Option | Description |
|
|
492
|
+
|--------|-------------|
|
|
493
|
+
| `--live` | Open the interactive dashboard |
|
|
494
|
+
| `--since <duration>` | Start of window (e.g. `7d`, `24h`, `today`) |
|
|
495
|
+
| `--until <duration>` | End of window (default: now) |
|
|
496
|
+
| `--format <format>` | `markdown`, `json`, or `table` |
|
|
497
|
+
| `--project <path>` | Absolute path to scope to |
|
|
498
|
+
| `--all-projects` | Aggregate across every project |
|
|
499
|
+
| `--model <id>` | Filter by model id |
|
|
500
|
+
| `--include-turns` | (JSON only) include per-turn records |
|
|
501
|
+
| `--verbose` | Print parse warnings and diagnostics |
|
|
502
|
+
|
|
503
|
+
### `invariant version`
|
|
504
|
+
|
|
505
|
+
Display the CLI version.
|
|
506
|
+
|
|
507
|
+
### `invariant update`
|
|
223
508
|
|
|
224
|
-
|
|
509
|
+
Update the CLI to the latest version, using the package manager it was installed with.
|
|
225
510
|
|
|
226
511
|
```bash
|
|
227
|
-
invariant
|
|
228
|
-
invariant
|
|
229
|
-
invariant
|
|
512
|
+
invariant update
|
|
513
|
+
invariant update --check
|
|
514
|
+
invariant update --version 0.5.4
|
|
230
515
|
```
|
|
231
516
|
|
|
232
|
-
|
|
|
233
|
-
|
|
234
|
-
| `-
|
|
235
|
-
| `-
|
|
236
|
-
| `-l, --language <langs...>` | Restrict to specific languages |
|
|
237
|
-
| `-f, --format <format>` | `json`, `markdown`, or `both` (default: `both`) |
|
|
238
|
-
| `--max-files <n>` | Cap total scanned files (default: 5000) |
|
|
239
|
-
| `--max-size <bytes>` | Skip files larger than this (default: 1 MB) |
|
|
517
|
+
| Option | Description |
|
|
518
|
+
|--------|-------------|
|
|
519
|
+
| `-v, --version <version>` | Update to a specific version |
|
|
520
|
+
| `-c, --check` | Only check whether an update is available |
|
|
240
521
|
|
|
241
|
-
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Project layout
|
|
525
|
+
|
|
526
|
+
After `init` + `install` + `sync`:
|
|
527
|
+
|
|
528
|
+
```
|
|
529
|
+
.
|
|
530
|
+
├── invariant.json # manifest: targets, packages, active items
|
|
531
|
+
├── .invariant/
|
|
532
|
+
│ ├── cache/ # downloaded packages
|
|
533
|
+
│ ├── contexts/ # rendered contexts
|
|
534
|
+
│ ├── instructions/ # rendered instructions
|
|
535
|
+
│ ├── sessions/ # `invariant plan` output
|
|
536
|
+
│ └── codegraph/ # `invariant scan` output
|
|
537
|
+
├── .agents/ # canonical store — the only physical copy
|
|
538
|
+
│ ├── skills/<name>/SKILL.md
|
|
539
|
+
│ ├── agents/<name>.md
|
|
540
|
+
│ ├── commands/<name>.md
|
|
541
|
+
│ └── rules/<name>.md
|
|
542
|
+
├── CLAUDE.md # generated by `invariant sync`
|
|
543
|
+
└── .claude/ # symlinks into .agents/
|
|
544
|
+
├── agents/<name>.md -> ../../.agents/agents/<name>.md
|
|
545
|
+
├── skills/<name> -> ../../.agents/skills/<name>
|
|
546
|
+
├── commands/<name>.md
|
|
547
|
+
└── rules/<name>.md
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### One copy, many views
|
|
551
|
+
|
|
552
|
+
`.agents/` holds the single physical copy of every activated item. What each
|
|
553
|
+
target gets depends on how it reads skills:
|
|
554
|
+
|
|
555
|
+
| Target | Skills | Agents / commands / rules |
|
|
556
|
+
|---|---|---|
|
|
557
|
+
| `claude` | symlink into `.agents/` | symlink into `.agents/` |
|
|
558
|
+
| `codex` | reads `.agents/skills/` — nothing written | embedded in `AGENTS.md` |
|
|
559
|
+
| `cursor` | reads `.agents/skills/` — nothing written | `.cursor/rules/<name>.mdc` |
|
|
560
|
+
| `copilot` | reads `.agents/skills/` — nothing written | `.github/instructions/<name>.instructions.md` |
|
|
561
|
+
| `aider` | embedded in `CONVENTIONS.md` | embedded in `CONVENTIONS.md` |
|
|
562
|
+
|
|
563
|
+
Two consequences worth knowing:
|
|
564
|
+
|
|
565
|
+
- Targets that speak the standard get **no invariant-written skill files**, so
|
|
566
|
+
they never read the same skill twice.
|
|
567
|
+
- Hand-written items you put in `.claude/skills/` yourself are never touched —
|
|
568
|
+
invariant only manages what is listed in `invariant.json → active`, plus links
|
|
569
|
+
that resolve into `.agents/`. A target file you edit by hand is kept, with a
|
|
570
|
+
warning, until you pass `--force`.
|
|
571
|
+
|
|
572
|
+
On hosts without symlink support the CLI falls back to a Windows junction, then
|
|
573
|
+
to a physical copy, and says which one it used. `invariant init --copy` (or
|
|
574
|
+
`"materialization": { "mode": "copy" }`) opts out of linking entirely.
|
|
575
|
+
|
|
576
|
+
### Version control
|
|
577
|
+
|
|
578
|
+
`.agents/` and the target folders are **generated** — they are rebuilt by
|
|
579
|
+
`invariant add` and `invariant sync`, the way `node_modules` is rebuilt by a
|
|
580
|
+
package manager. `init` and `sync` keep them out of git via a delimited block:
|
|
581
|
+
|
|
582
|
+
```gitignore
|
|
583
|
+
# --- invariant (generated, do not edit) ---
|
|
584
|
+
.agents/
|
|
585
|
+
.claude/agents/
|
|
586
|
+
.claude/skills/
|
|
587
|
+
.claude/commands/
|
|
588
|
+
.claude/rules/
|
|
589
|
+
CLAUDE.md
|
|
590
|
+
# --- end invariant ---
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
Only paths invariant owns outright are listed, so a folder you share with it
|
|
594
|
+
(`.cursor/rules/`, which also holds your own rules) is left alone. Commit
|
|
595
|
+
`invariant.json`, run `invariant sync` after a clone.
|