ggen 2.7.1

ggen is a deterministic, language-agnostic code generation framework that treats software artifacts as projections of knowledge graphs.
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
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [CLI Reference]#cli-reference
  - [Global Options]#global-options
  - [Commands Overview]#commands-overview
  - [Marketplace Commands]#marketplace-commands
    - [ggen marketplace search]#ggen-marketplace-search
    - [ggen marketplace install]#ggen-marketplace-install
    - [ggen marketplace list]#ggen-marketplace-list
    - [ggen marketplace publish]#ggen-marketplace-publish
  - [AI Commands]#ai-commands
    - [ggen ai generate-ontology]#ggen-ai-generate-ontology
    - [ggen ai chat]#ggen-ai-chat
    - [ggen ai analyze]#ggen-ai-analyze
  - [Template Commands]#template-commands
    - [ggen template generate-rdf]#ggen-template-generate-rdf
    - [ggen template list]#ggen-template-list
    - [ggen template lint]#ggen-template-lint
  - [Graph Commands]#graph-commands
    - [ggen graph load]#ggen-graph-load
    - [ggen graph query]#ggen-graph-query
    - [ggen graph validate]#ggen-graph-validate
    - [ggen graph export]#ggen-graph-export
  - [Hook Commands]#hook-commands
    - [ggen hook create]#ggen-hook-create
    - [ggen hook list]#ggen-hook-list
    - [ggen hook remove]#ggen-hook-remove
    - [ggen hook monitor]#ggen-hook-monitor
  - [Project Commands]#project-commands
    - [ggen project new]#ggen-project-new
    - [ggen project gen]#ggen-project-gen
  - [Utils Commands]#utils-commands
    - [ggen utils doctor]#ggen-utils-doctor
    - [ggen utils env]#ggen-utils-env
  - [Command Examples]#command-examples
    - [Complete Workflow]#complete-workflow
    - [Marketplace Workflow]#marketplace-workflow
  - [Exit Codes]#exit-codes
  - [See Also]#see-also

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# CLI Reference

Complete reference for all `ggen` command-line interface commands.

## Global Options

All commands support these global flags:

```bash
--help, -h          Show help information
--version, -V       Show version information
--json              Output in JSON format
--verbose, -v       Enable verbose output
--quiet, -q         Suppress output
```

## Commands Overview

ggen provides seven main command categories:

- **marketplace** - Search, install, and publish templates
- **project** - Create and manage projects
- **ai** - AI-powered code generation and analysis
- **template** - Template management and generation
- **hook** - Git hooks and automation
- **graph** - RDF graph operations
- **utils** - System utilities and diagnostics

## Marketplace Commands

### ggen marketplace search

Search for packages in the marketplace.

**Usage:**
```bash
ggen marketplace search <QUERY> [OPTIONS]
```

**Arguments:**
- `<QUERY>` - Search query string

**Options:**
- `--limit <N>` - Maximum number of results (default: 10)
- `--category <CAT>` - Filter by category

**Examples:**
```bash
ggen marketplace search "rust microservice"
ggen marketplace search "api" --category backend --limit 20
```

### ggen marketplace install

Install a package from the marketplace.

**Usage:**
```bash
ggen marketplace install <PACKAGE_ID> [OPTIONS]
```

**Arguments:**
- `<PACKAGE_ID>` - Package identifier (e.g., `io.ggen.rust.microservice`)

**Options:**
- `--version <VERSION>` - Install specific version
- `--force` - Force reinstall

**Examples:**
```bash
ggen marketplace install io.ggen.rust.microservice
ggen marketplace install io.ggen.rust.microservice --version 1.2.0
```

### ggen marketplace list

List installed packages.

**Usage:**
```bash
ggen marketplace list [OPTIONS]
```

**Options:**
- `--json` - Output as JSON

**Examples:**
```bash
ggen marketplace list
ggen marketplace list --json
```

### ggen marketplace publish

Publish a package to the marketplace.

**Usage:**
```bash
ggen marketplace publish [OPTIONS]
```

**Options:**
- `--name <NAME>` - Package name
- `--version <VERSION>` - Package version
- `--template-dir <DIR>` - Template directory

**Examples:**
```bash
ggen marketplace publish --name my-template --version 1.0.0 --template-dir ./templates
```

## AI Commands

### ggen ai generate-ontology

Generate an RDF ontology using AI.

**Usage:**
```bash
ggen ai generate-ontology --prompt <PROMPT> --output <FILE> [OPTIONS]
```

**Arguments:**
- `--prompt <PROMPT>` - Natural language description of domain
- `--output <FILE>` - Output RDF file path

**Options:**
- `--provider <PROVIDER>` - AI provider (anthropic, openai, ollama)
- `--model <MODEL>` - Model name

**Examples:**
```bash
ggen ai generate-ontology --prompt "E-commerce: Product, Order, Customer" --output domain.ttl
```

### ggen ai chat

Interactive AI chat session.

**Usage:**
```bash
ggen ai chat [OPTIONS]
```

**Options:**
- `--interactive` - Interactive mode
- `--prompt <PROMPT>` - Single prompt
- `--input <FILE>` - Input file

**Examples:**
```bash
ggen ai chat --interactive
ggen ai chat --prompt "Improve this ontology" --input domain.ttl
```

### ggen ai analyze

Analyze codebase with AI.

**Usage:**
```bash
ggen ai analyze <PATH> [OPTIONS]
```

**Arguments:**
- `<PATH>` - Path to analyze

**Options:**
- `--focus <ASPECT>` - Focus area (domain-model, architecture, etc.)
- `--suggest-improvements` - Suggest improvements

**Examples:**
```bash
ggen ai analyze src/ --focus domain-model
```

## Template Commands

### ggen template generate-rdf

Generate code from RDF ontology using template.

**Usage:**
```bash
ggen template generate-rdf --ontology <FILE> --template <TEMPLATE> --output <DIR> [OPTIONS]
```

**Arguments:**
- `--ontology <FILE>` - RDF ontology file
- `--template <TEMPLATE>` - Template name or path
- `--output <DIR>` - Output directory

**Options:**
- `--vars <KEY=VALUE>` - Template variables
- `--dry-run` - Show what would be generated

**Examples:**
```bash
ggen template generate-rdf --ontology domain.ttl --template rust-models --output src/
```

### ggen template list

List available templates.

**Usage:**
```bash
ggen template list [OPTIONS]
```

**Examples:**
```bash
ggen template list
```

### ggen template lint

Validate template syntax.

**Usage:**
```bash
ggen template lint <TEMPLATE> [OPTIONS]
```

**Arguments:**
- `<TEMPLATE>` - Template file or name

**Examples:**
```bash
ggen template lint templates/rust-models/models.rs.tmpl
```

## Graph Commands

### ggen graph load

Load RDF graph from file.

**Usage:**
```bash
ggen graph load <FILE> [OPTIONS]
```

**Arguments:**
- `<FILE>` - RDF file path

**Examples:**
```bash
ggen graph load domain.ttl
```

### ggen graph query

Execute SPARQL query against graph.

**Usage:**
```bash
ggen graph query <FILE> --sparql <QUERY> [OPTIONS]
```

**Arguments:**
- `<FILE>` - RDF file path
- `--sparql <QUERY>` - SPARQL query string

**Options:**
- `--file <FILE>` - SPARQL query file

**Examples:**
```bash
ggen graph query domain.ttl --sparql "SELECT ?s ?p ?o WHERE { ?s ?p ?o } LIMIT 10"
```

### ggen graph validate

Validate RDF graph.

**Usage:**
```bash
ggen graph validate <FILE> [OPTIONS]
```

**Arguments:**
- `<FILE>` - RDF file path

**Options:**
- `--shacl <FILE>` - SHACL shapes file
- `--verbose` - Verbose output

**Examples:**
```bash
ggen graph validate domain.ttl
ggen graph validate domain.ttl --shacl shapes.ttl
```

### ggen graph export

Export graph to different format.

**Usage:**
```bash
ggen graph export <FILE> --format <FORMAT> [OPTIONS]
```

**Arguments:**
- `<FILE>` - RDF file path
- `--format <FORMAT>` - Output format (turtle, json-ld, n-triples)

**Examples:**
```bash
ggen graph export domain.ttl --format json-ld
```

## Hook Commands

### ggen hook create

Create a Git hook.

**Usage:**
```bash
ggen hook create <PHASE> --name <NAME> --command <CMD> [OPTIONS]
```

**Arguments:**
- `<PHASE>` - Lifecycle phase (pre-commit, post-merge, etc.)
- `--name <NAME>` - Hook name
- `--command <CMD>` - Command to execute

**Examples:**
```bash
ggen hook create pre-commit --name validate --command "ggen graph validate domain.ttl"
```

### ggen hook list

List registered hooks.

**Usage:**
```bash
ggen hook list [OPTIONS]
```

**Examples:**
```bash
ggen hook list
```

### ggen hook remove

Remove a hook.

**Usage:**
```bash
ggen hook remove <PHASE> <NAME>
```

**Arguments:**
- `<PHASE>` - Lifecycle phase
- `<NAME>` - Hook name

**Examples:**
```bash
ggen hook remove pre-commit validate
```

### ggen hook monitor

Monitor hook execution.

**Usage:**
```bash
ggen hook monitor [OPTIONS]
```

**Examples:**
```bash
ggen hook monitor
```

## Project Commands

### ggen project new

Create a new project.

**Usage:**
```bash
ggen project new <NAME> [OPTIONS]
```

**Arguments:**
- `<NAME>` - Project name

**Options:**
- `--type <TYPE>` - Project type
- `--framework <FRAMEWORK>` - Framework name

**Examples:**
```bash
ggen project new my-app --type rust-web --framework axum
```

### ggen project gen

Generate code from project plan.

**Usage:**
```bash
ggen project gen <NAME> [OPTIONS]
```

**Arguments:**
- `<NAME>` - Project name

**Options:**
- `--template <TEMPLATE>` - Template to use
- `--vars <KEY=VALUE>` - Variables

**Examples:**
```bash
ggen project gen my-service --template io.ggen.rust.microservice
```

## Utils Commands

### ggen utils doctor

System diagnostics and health check.

**Usage:**
```bash
ggen utils doctor [OPTIONS]
```

**Examples:**
```bash
ggen utils doctor
```

### ggen utils env

Environment variable management.

**Usage:**
```bash
ggen utils env [OPTIONS]
```

**Examples:**
```bash
ggen utils env
```

## Command Examples

### Complete Workflow

```bash
# 1. Generate ontology
ggen ai generate-ontology --prompt "Blog system" --output blog.ttl

# 2. Validate ontology
ggen graph validate blog.ttl

# 3. Generate Rust code
ggen template generate-rdf --ontology blog.ttl --template rust-models --output src/

# 4. Set up hook for auto-regeneration
ggen hook create post-merge --name regenerate --command "ggen template generate-rdf --ontology blog.ttl --template rust-models --output src/"
```

### Marketplace Workflow

```bash
# 1. Search for templates
ggen marketplace search "rust api"

# 2. Install template
ggen marketplace install io.ggen.rust.axum-api

# 3. Use template
ggen template generate-rdf --ontology domain.ttl --template io.ggen.rust.axum-api --output src/
```

## Exit Codes

- `0` - Success
- `1` - General error
- `2` - Invalid arguments
- `3` - File not found
- `4` - Validation error

## See Also

- [Getting Started Tutorial]../tutorials/getting-started.md
- [Installation Guide]../how-to-guides/installation.md
- [Troubleshooting Guide]../how-to-guides/troubleshoot.md