Skip to content

Commit 3713a52

Browse files
committed
docs: add usage examples to agent, init, and compact commands
Add Examples sections to the Long description of commands that have meaningful flags, following the pattern established in add.go. Signed-off-by: Jose Alekhinne <alekhinejose@gmail.com>
1 parent 68342bb commit 3713a52

3 files changed

Lines changed: 41 additions & 8 deletions

File tree

internal/cli/agent.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ It includes:
3838
- Recent decisions
3939
4040
Use --budget to limit token output (default 8000).
41-
Use --format to choose between markdown (md) or JSON output.`,
41+
Use --format to choose between markdown (md) or JSON output.
42+
43+
Examples:
44+
ctx agent # Default 8000 token budget, markdown output
45+
ctx agent --budget 4000 # Smaller context packet for limited contexts
46+
ctx agent --format json # JSON output for programmatic use
47+
ctx agent --budget 2000 --format json`,
4248
RunE: runAgent,
4349
}
4450

internal/cli/compact.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,27 @@ Actions performed:
3838
- Remove empty sections from context files
3939
- Report on potential duplicates
4040
41-
Use --archive to create .context/archive/ for old content.`,
41+
Use --archive to create .context/archive/ for old content.
42+
43+
Examples:
44+
ctx compact # Clean up context, move completed tasks
45+
ctx compact --archive # Also archive old tasks to .context/archive/
46+
ctx compact --no-auto-save # Skip pre-compact session snapshot`,
4247
RunE: runCompact,
4348
}
4449

45-
cmd.Flags().BoolVar(&compactArchive, "archive", false, "Create .context/archive/ for old content")
46-
cmd.Flags().BoolVar(&compactNoAutoSave, "no-auto-save", false, "Skip auto-saving session before compact")
50+
cmd.Flags().BoolVar(
51+
&compactArchive,
52+
"archive",
53+
false,
54+
"Create .context/archive/ for old content",
55+
)
56+
cmd.Flags().BoolVar(
57+
&compactNoAutoSave,
58+
"no-auto-save",
59+
false,
60+
"Skip auto-saving session before compact",
61+
)
4762

4863
return cmd
4964
}
@@ -106,7 +121,9 @@ func runCompact(cmd *cobra.Command, _ []string) error {
106121
return nil
107122
}
108123

109-
func compactTasks(cmd *cobra.Command, ctx *context.Context, archive bool) (int, error) {
124+
func compactTasks(
125+
cmd *cobra.Command, ctx *context.Context, archive bool,
126+
) (int, error) {
110127
var tasksFile *context.FileInfo
111128
for i := range ctx.Files {
112129
if ctx.Files[i].Name == "TASKS.md" {
@@ -147,7 +164,10 @@ func compactTasks(cmd *cobra.Command, ctx *context.Context, archive bool) (int,
147164
matches := completedPattern.FindStringSubmatch(line)
148165
if len(matches) > 1 {
149166
completedTasks = append(completedTasks, matches[1])
150-
cmd.Printf("%s Moving completed task: %s\n", green("✓"), truncateString(matches[1], 50))
167+
cmd.Printf(
168+
"%s Moving completed task: %s\n", green("✓"),
169+
truncateString(matches[1], 50),
170+
)
151171
changes++
152172
continue // Don't add to newLines
153173
}
@@ -163,7 +183,8 @@ func compactTasks(cmd *cobra.Command, ctx *context.Context, archive bool) (int,
163183
if strings.HasPrefix(line, "## Completed") {
164184
// Find the next line that's either empty or another section
165185
insertIdx := i + 1
166-
for insertIdx < len(newLines) && newLines[insertIdx] != "" && !strings.HasPrefix(newLines[insertIdx], "## ") {
186+
for insertIdx < len(newLines) && newLines[insertIdx] != "" &&
187+
!strings.HasPrefix(newLines[insertIdx], "## ") {
167188
insertIdx++
168189
}
169190

internal/cli/init.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ The following files are created:
6767
- DRIFT.md — Staleness signals and update triggers
6868
- AGENT_PLAYBOOK.md — How AI agents should use this system
6969
70-
Use --minimal to only create essential files (TASKS.md, DECISIONS.md, CONSTITUTION.md).`,
70+
Use --minimal to only create essential files (TASKS.md, DECISIONS.md, CONSTITUTION.md).
71+
72+
Examples:
73+
ctx init # Full initialization with all templates
74+
ctx init --minimal # Only essential files (TASKS, DECISIONS, CONSTITUTION)
75+
ctx init --force # Overwrite existing files without prompting
76+
ctx init --merge # Auto-merge ctx content into existing CLAUDE.md`,
7177
RunE: runInit,
7278
}
7379

0 commit comments

Comments
 (0)