1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
//! CLI command model: the clap `Parser`/`Subcommand` types.
//!
//! Defined in the library (not `main.rs`) so both the `murk` binary and the
//! `doc-gen` tool build the exact same command tree from `Cli::command()`.
use clap::{Parser, Subcommand};
/// Encrypted secrets manager for developers.
#[derive(Parser)]
#[command(name = "murk", version, about)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
// Setup & recovery
/// Initialize a new vault and generate a keypair
Init {
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Write a .envrc for direnv integration
Env {
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Restore MURK_KEY from a BIP39 recovery phrase
Restore {
/// Vault filename, for the restored-identity recipient check
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Re-derive recovery phrase from current MURK_KEY
Recover,
// Secrets
/// Add or update a secret
Add {
/// Secret key name
key: String,
/// Description for this key
#[arg(long)]
desc: Option<String>,
/// Who can read it: a group name, `everyone` (default), or `me`
#[arg(long)]
group: Option<String>,
/// Deprecated alias for `--group me`
#[arg(long, hide = true)]
scoped: bool,
/// Tag for grouping (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Generate a random secret and store it
Generate {
/// Secret key name
key: String,
/// Length in bytes (default 32)
#[arg(long, default_value = "32")]
length: usize,
/// Output as hex instead of base64
#[arg(long)]
hex: bool,
/// Description for this key
#[arg(long)]
desc: Option<String>,
/// Who can read it: a group name, `everyone` (default), or `me`
#[arg(long)]
group: Option<String>,
/// Tag for grouping (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Rotate secrets with new values
Rotate {
/// Secret key name (omit for --all)
key: Option<String>,
/// Rotate all secrets in the vault
#[arg(long)]
all: bool,
/// Generate random values instead of prompting
#[arg(long)]
generate: bool,
/// Length in bytes for generated values (default 32)
#[arg(long, default_value = "32")]
length: usize,
/// Output generated values as hex instead of base64
#[arg(long)]
hex: bool,
/// List keys needing rotation instead of rotating (exits 1 if any)
#[arg(long, conflicts_with_all = ["key", "all", "generate", "hex"])]
list: bool,
/// Output the listing as JSON (with --list; always exits 0)
#[arg(long, requires = "list", conflicts_with_all = ["key", "all", "generate", "hex"])]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Remove a secret
Rm {
/// Secret key name
key: String,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Get a single decrypted value
Get {
/// Secret key name
key: String,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Edit secrets in $EDITOR
Edit {
/// Edit a single key (omit to edit all)
key: Option<String>,
/// Edit scoped overrides instead of shared secrets
#[arg(long)]
scoped: bool,
/// Edit values for this group instead of shared secrets
#[arg(long)]
group: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// List all key names
Ls {
/// Filter by tag (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Export all secrets as shell export statements
Export {
/// Filter by tag (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Import secrets from a .env file
Import {
/// Path to the .env file to import
#[arg(default_value = ".env")]
file: String,
/// Overwrite existing secrets without prompting
#[arg(long)]
force: bool,
/// Assign imported secrets to this group (default: everyone)
#[arg(long)]
group: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
// Metadata & inspection
/// Add or update a key description
Describe {
/// Secret key name
key: String,
/// Description text
description: String,
/// Example value
#[arg(long)]
example: Option<String>,
/// Tag for grouping (repeatable, replaces existing tags)
#[arg(long)]
tag: Vec<String>,
/// Rotation interval, e.g. `90d` or `90` (days); `never` clears it
#[arg(long, value_name = "DAYS")]
rotate_every: Option<String>,
/// Hard expiry date, e.g. `2026-09-01`; `never` clears it
#[arg(long, value_name = "DATE")]
expires: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Show public schema and key info
Info {
/// Filter by tag (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Export schema-only vault with no secrets or recipients
Skeleton {
/// Output file (prints to stdout if omitted)
#[arg(long, short)]
output: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
// Run
/// Run a command with secrets injected as environment variables
#[command(trailing_var_arg = true)]
Exec {
/// Only inject these specific keys (repeatable)
#[arg(long)]
only: Vec<String>,
/// Filter by tag (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Strip inherited environment (only murk secrets + PATH)
#[arg(long)]
clean_env: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
/// Command and arguments to execute
#[arg(required = true)]
command: Vec<String>,
},
// Agents
/// Agent-oriented commands (schema-only output for AI agent prompts)
Agent {
#[command(subcommand)]
sub: AgentCommand,
},
/// Run an MCP (Model Context Protocol) stdio server for AI agents
Mcp {
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
/// Enable the murk_exec tool (run commands with scoped secrets injected).
/// Off by default: it runs arbitrary commands as this user — the injected
/// secrets are grant-scoped, but the command itself is not sandboxed.
#[arg(long = "allow-exec")]
allow_exec: bool,
},
/// Manage the agent access policy
Policy {
#[command(subcommand)]
sub: PolicyCommand,
},
// Recipients & groups
/// Manage recipients
#[command(alias = "recipients")]
Circle {
#[command(subcommand)]
sub: Option<CircleCommand>,
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Add a recipient to the vault
#[command(hide = true)]
Authorize {
/// Public key (age1...), ssh:path, ssh: (default ~/.ssh/id_ed25519.pub), or github:username
pubkey: String,
/// Display name for this recipient
#[arg(long)]
name: Option<String>,
/// Accept changed GitHub keys without confirmation
#[arg(long)]
force: bool,
/// Allow ssh-rsa recipients (rejected by default — use ed25519)
#[arg(long)]
allow_ssh_rsa: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Remove a recipient from the vault
#[command(hide = true)]
Revoke {
/// Recipient pubkey or display name
recipient: String,
/// Rotate the secrets they had access to in the same session
#[arg(long)]
rotate: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Manage recipient groups
Group {
#[command(subcommand)]
sub: GroupCommand,
},
// Checks
/// Verify vault integrity without exporting secrets
Verify {
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Check the surrounding repo for hygiene issues
Doctor {
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Scan files for leaked secret values
Scan {
/// Files or directories to scan (defaults to current directory)
paths: Vec<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
// Git integration
/// Show secret changes vs a git ref
Diff {
/// Git ref to compare against
#[arg(default_value = "HEAD")]
git_ref: String,
/// Show actual values (not just key names)
#[arg(long)]
show_values: bool,
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Configure git to use murk's merge driver for .murk files
#[command(name = "setup-merge-driver")]
SetupMergeDriver,
/// Git merge driver for .murk vault files (called by git)
#[command(name = "merge-driver", hide = true)]
MergeDriver {
/// Path to base version (%O)
base: String,
/// Path to ours version (%A) — result is written here
ours: String,
/// Path to theirs version (%B)
theirs: String,
},
// Shell
/// Generate or install shell completions
Completion {
#[command(subcommand)]
action: CompletionAction,
},
}
#[derive(Subcommand)]
pub enum CompletionAction {
/// Print completions to stdout
Generate {
/// Shell to generate completions for
shell: clap_complete::Shell,
},
/// Install completions to the standard path
Install {
/// Shell to install completions for
shell: clap_complete::Shell,
},
}
#[derive(Subcommand)]
pub enum AgentCommand {
/// Emit schema-only context safe to paste into an AI agent prompt
Plan {
/// Filter by tag (repeatable)
#[arg(long)]
tag: Vec<String>,
/// Output as JSON
#[arg(long)]
json: bool,
/// Output file (prints to stdout if omitted)
#[arg(long, short)]
output: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Run a command with strict agent-safe defaults (clears the inherited
/// environment, strips MURK_KEY, requires --only)
#[command(trailing_var_arg = true)]
Exec {
/// Inject these specific keys (required — agent mode fails closed)
#[arg(long, required = true)]
only: Vec<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
/// Command and arguments to execute
#[arg(required = true)]
command: Vec<String>,
},
/// Mint a short-lived ephemeral key that can read only the named secrets
Grant {
/// Grant name (used to revoke it later)
#[arg(long)]
name: String,
/// Keys this grant can read (required — fails closed)
#[arg(long, required = true)]
only: Vec<String>,
/// Time to live, e.g. 30m, 2h, 7d (advisory — see `agent revoke`)
#[arg(long, default_value = "2h")]
ttl: String,
/// Where to write the agent key: a path, or `-` for stdout
#[arg(long)]
out: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// One-shot onboarding: optionally set the agent allow-list, mint a scoped
/// grant, and print how to run the agent safely
Init {
/// Grant name (used to revoke it later)
#[arg(long)]
name: String,
/// Keys the agent can read (required — fails closed)
#[arg(long, required = true)]
only: Vec<String>,
/// Set the agent allow-list to these tags before granting (repeatable)
#[arg(long = "allow-tag")]
allow_tag: Vec<String>,
/// Time to live, e.g. 30m, 2h, 7d (advisory — see `agent revoke`)
#[arg(long, default_value = "2h")]
ttl: String,
/// Where to write the agent key: a path, or `-` for stdout
#[arg(long)]
out: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// List active agent grants and their TTLs
Ls {
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Revoke an agent grant and rotate the keys it could read
Revoke {
/// Grant name
name: String,
/// Rotate the keys it could read in the same session
#[arg(long)]
rotate: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Wire `murk mcp` into an AI editor's MCP config, minting a scoped grant.
/// No CLIENT auto-detects installed editors; give one (claude, cursor,
/// vscode, zed, gemini, omp, codex) to target it.
Connect {
/// Editor to configure; omit to auto-detect
/// (claude, cursor, vscode, zed, gemini, omp, codex)
client: Option<String>,
/// Keys the agent may read (required — fails closed)
#[arg(long, required = true)]
only: Vec<String>,
/// Set the agent allow-list to these tags before granting (repeatable)
#[arg(long = "allow-tag")]
allow_tag: Vec<String>,
/// Also expose `murk agent exec` to the agent (adds --allow-exec)
#[arg(long)]
allow_exec: bool,
/// Grant time to live, e.g. 30m, 2h, 7d (advisory — see `agent revoke`)
#[arg(long, default_value = "2h")]
ttl: String,
/// Grant name (used to disconnect/revoke it later)
#[arg(long, default_value = "mcp")]
name: String,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Remove murk's entry from an AI editor's MCP config. No CLIENT clears every
/// configured editor; `--rotate` also revokes the grant and rotates its keys.
Disconnect {
/// Editor to disconnect; omit for every configured editor
client: Option<String>,
/// Revoke the grant and rotate the keys it could read
#[arg(long)]
rotate: bool,
/// Grant name to revoke with --rotate
#[arg(long, default_value = "mcp")]
name: String,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
}
#[derive(Subcommand)]
pub enum CircleCommand {
/// Add a recipient to the vault
Authorize {
/// Public key (age1...), ssh:path, ssh: (default ~/.ssh/id_ed25519.pub), or github:username
pubkey: String,
/// Display name for this recipient
#[arg(long)]
name: Option<String>,
/// Also add the new recipient to this group
#[arg(long)]
group: Option<String>,
/// Accept changed GitHub keys without confirmation
#[arg(long)]
force: bool,
/// Allow ssh-rsa recipients (rejected by default — use ed25519)
#[arg(long)]
allow_ssh_rsa: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Remove a recipient from the vault
Revoke {
/// Recipient pubkey or display name
recipient: String,
/// Rotate the secrets they had access to in the same session
#[arg(long)]
rotate: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
}
#[derive(Subcommand)]
pub enum GroupCommand {
/// Create a new recipient group (you become its first member)
Create {
/// Group name
name: String,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// List groups and their members
Ls {
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Add a member to a group
Add {
/// Group name
name: String,
/// Recipient pubkey or display name to add
#[arg(long)]
member: String,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Remove a member from a group, or delete the group entirely
Rm {
/// Group name
name: String,
/// Recipient pubkey or display name to remove (omit to delete the group)
#[arg(long)]
member: Option<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
}
#[derive(Subcommand)]
pub enum PolicyCommand {
/// Show the agent access policy (works without a key)
Show {
/// Output as JSON
#[arg(long)]
json: bool,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Set the agent allow-list: agents may only receive secrets carrying one of these tags
Set {
/// Tag agents are allowed to receive (repeatable, required)
#[arg(long = "allow-tag", required = true)]
allow_tag: Vec<String>,
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
/// Remove the policy — agent mode becomes unrestricted again
Clear {
/// Vault filename
#[arg(long, env = "MURK_VAULT", default_value = ".murk")]
vault: String,
},
}