scud-cli 1.67.0

Fast, simple task master for AI-driven development
Documentation
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
# SCUD CLI (Rust)

Fast, simple task master for AI-driven development - Rust implementation.

## Overview

This is a high-performance Rust rewrite of the SCUD task management system. It replaces the external `task-master` CLI with a fast, single-binary solution that:

- **50x faster** startup time (~10ms vs ~500ms)
- 🎯 **42x token reduction** (~500 tokens vs ~21k tokens per operation)
- 📦 **Simple distribution** - single binary, no dependencies
- 🔧 **Direct LLM integration** - no MCP overhead

## Architecture

```
scud (Rust Binary)
├── Core Commands (No AI - Instant)
│   ├── init               # Initialize .scud/ and install agents
│   ├── tags               # List tags or set active tag
│   ├── list               # List tasks with filters
│   ├── view               # Open interactive HTML viewer in browser
│   ├── show               # Show task details
│   ├── set-status         # Update task status
│   ├── next               # Find next available task
│   ├── stats              # Show statistics
│   └── doctor             # [EXPERIMENTAL] Diagnose stuck states
│
├── AI Commands (Direct LLM API)
│   ├── parse-prd          # Parse PRD markdown into tasks
│   ├── analyze-complexity # Analyze task complexity
│   ├── expand             # Break down complex tasks
│   └── reanalyze-deps     # Analyze cross-tag dependencies
│
├── Agent Execution
│   ├── spawn              # Spawn agents in tmux windows
│   ├── ralph              # Sequential iteration loop
│   ├── swarm              # Wave-based parallel execution
│   └── agent-exec         # [direct-api] Direct API agentic loop
│
└── Storage (SCG)
    └── .scud/tasks/tasks.scg
```

## Installation

### Option 1: npm (Recommended)

Install globally via npm - this will build the Rust binary automatically:

```bash
npm install -g scud-task
```

**Requirements:** Rust toolchain must be installed ([rustup.rs](https://rustup.rs/))

### Option 2: Cargo

Install directly via Cargo:

```bash
cargo install scud-cli
```

With direct API support (replaces `claude -p` harness with native API calls):

```bash
cargo install scud-cli --features direct-api
```

Or build from source:

```bash
git clone https://github.com/pyrex41/scud.git
cd scud/scud-cli
cargo install --path .
# Or with direct API support:
cargo install --path . --features direct-api
```

### Verify Installation

```bash
scud --version
scud --help
```

## Building (Development)

### Debug Build
```bash
cargo build
```

### Release Build
```bash
cargo build --release
```

## Usage

### Core Commands

```bash
# Initialize SCUD
scud init

# List tags
scud tags

# Switch to a tag
scud tags auth

# List tasks
scud list
scud list --status pending

# Show task details
scud show 3

# Update task status
scud set-status 3 in-progress

# Find next available task
scud next

# Show statistics
scud stats

# Open interactive task viewer in browser
scud view

# Clean up tasks (archives by default)
scud clean                    # Archive all tags
scud clean --tag auth         # Archive specific tag
scud clean --list             # List archived phases
scud clean --restore <name>   # Restore archived phase
scud clean --delete           # Permanently delete (use with caution)
```

> **Note:** `scud clean` archives tasks by default instead of deleting them. This provides a safety net for accidental cleanups. Use `--delete` to permanently remove tasks. Archives are stored in `.scud/archive/`.

### [EXPERIMENTAL] Doctor Command

Diagnose stuck workflow states:

```bash
# Check for issues in all tags
scud doctor

# Check specific tag with custom stale threshold
scud doctor --tag auth --stale-hours 12

# Auto-fix recoverable issues (stale locks, orphan tasks)
scud doctor --fix
```

The doctor command detects:
- Stale locks (tasks locked >24h by default)
- Tasks blocked by cancelled/missing dependencies
- Orphan in-progress tasks (not locked, stale)
- Missing active tag
- Corrupt storage files

### AI Commands

**Requires:** API key environment variable (see [Provider Configuration](#provider-configuration))

```bash
# Parse PRD into tasks
scud parse-prd docs/features/auth.md --tag auth

# Analyze complexity
scud analyze-complexity                # All tasks
scud analyze-complexity --task 5       # Specific task

# Expand complex tasks
scud expand 7                          # Specific task
scud expand --all                      # All tasks >13 complexity

# Reanalyze cross-tag dependencies
scud reanalyze-deps --all-tags
```

### UUID Task IDs

For integration with external tools that expect UUID task IDs (like Descartes):

```bash
# Generate tasks with UUID IDs instead of sequential numbers
scud parse requirements.md --tag myproject --id-format uuid
```

This generates tasks with 32-character UUID identifiers (e.g., `a1b2c3d4e5f6789012345678901234ab`) instead of sequential numbers (`1`, `2`, `3`).

**Key behaviors:**
- Sequential IDs remain the default for backwards compatibility
- The ID format is stored in the phase metadata and inherited during expansion
- Subtasks also get UUID IDs when the parent phase uses UUID format
- Long UUIDs are truncated in CLI output (`a1b2c3d4...`) for readability
- The `scud show` command displays the full UUID

## Performance Comparison

| Operation | Old (task-master) | New (Rust) | Improvement |
|-----------|------------------|------------|-------------|
| Startup | ~500ms | ~10ms | **50x faster** |
| List tasks | ~100ms | ~5ms | **20x faster** |
| Parse PRD | ~3-5s | ~2-3s | ~40% faster |
| Token overhead | ~21k | ~500 | **42x reduction** |

## Provider Configuration

SCUD supports multiple LLM providers: **xAI (Grok)**, **Anthropic (Claude)**, **OpenAI (GPT)**, and **OpenRouter**.

### Quick Start

```bash
# Initialize with xAI (Grok) - recommended for fast code generation
scud init --provider xai
export XAI_API_KEY=your-key

# Or initialize with Anthropic (Claude)
scud init --provider anthropic
export ANTHROPIC_API_KEY=your-key

# Interactive mode - prompt for provider
scud init
```

### Configuration File

The configuration is stored in `.scud/config.toml`:

```toml
[llm]
provider = "xai"
model = "xai/grok-code-fast-1"
max_tokens = 4096
```

For complete provider documentation, see [PROVIDERS.md](./PROVIDERS.md).

### Supported Providers

| Provider | Environment Variable | Default Model |
|----------|---------------------|---------------|
| xAI | `XAI_API_KEY` | `xai/grok-code-fast-1` |
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4-20250514` |
| OpenAI | `OPENAI_API_KEY` | `gpt-4-turbo` |
| OpenRouter | `OPENROUTER_API_KEY` | `anthropic/claude-sonnet-4` |

## Data Models

### Task
```rust
struct Task {
    id: String,
    title: String,
    description: String,
    status: TaskStatus,         // pending, in-progress, done, etc.
    complexity: u32,            // Fibonacci scale: 1,2,3,5,8,13,21
    priority: Priority,         // high, medium, low
    dependencies: Vec<String>,  // Task IDs this depends on
    details: Option<String>,    // Technical details
    test_strategy: Option<String>,
    complexity_analysis: Option<String>,
    created_at: Option<String>,
    updated_at: Option<String>,
}
```

### Phase
```rust
struct Phase {
    name: String,
    tasks: Vec<Task>,
    id_format: IdFormat,  // sequential (default) or uuid
}
```

### Config
```toml
[llm]
provider = "xai"
model = "xai/grok-code-fast-1"
max_tokens = 4096
```

## LLM Integration

### Direct Anthropic API
- No MCP server overhead
- Simple HTTP requests
- Minimal token usage
- Fast response times

### Direct API Agentic Runner (Feature: `direct-api`)

An optional feature that replaces the `claude -p` subprocess harness with direct Anthropic API calls. Instead of spawning an external CLI, scud runs its own agentic loop: send messages with tool definitions, execute tool_use blocks locally, return results, repeat.

**Authentication:** Uses OAuth tokens from Claude Code's macOS Keychain (subscription billing), with fallback to `ANTHROPIC_API_KEY`.

**Tools available to the agent:** Read, Write, Edit, Bash, Search (ripgrep), Find (fd)

**Usage:**

```bash
# Build with the feature
cargo build --features direct-api

# Run directly
scud agent-exec --prompt "Fix the failing tests"
scud agent-exec --prompt-file /tmp/task-prompt.txt --model claude-sonnet-4-5-20250929

# Use via ralph/swarm (set in .scud/config.toml)
# [swarm]
# use_direct_api = true

# Or pass --harness direct-api to ralph/spawn/swarm commands
scud ralph --harness direct-api --tag mytag
```

**Note:** This feature is gated behind `--features direct-api` because it relies on Claude Code OAuth token impersonation which may stop working if Anthropic changes requirements.

### Prompt Templates

Located in `src/llm/prompts.rs`:
- `parse_prd()` - Converts markdown to structured tasks
- `analyze_complexity()` - Scores task difficulty
- `expand_task()` - Breaks down complex tasks
- `reanalyze_dependencies()` - Cross-tag dependency analysis

## Integration with SCUD

The Rust CLI integrates seamlessly with the existing SCUD system:

1. `bin/scud.js` detects and delegates to Rust binary
2. Falls back to debug build if release not available
3. Auto-builds if binary not found
4. All agents and slash commands work unchanged

## Development

### Project Structure

```
scud-cli/
├── Cargo.toml
├── src/
│   ├── main.rs              # CLI entry point
│   ├── commands/
│   │   ├── mod.rs
│   │   ├── init.rs          # Core commands
│   │   ├── tags.rs
│   │   ├── ...
│   │   └── ai/              # AI commands
│   │       ├── parse_prd.rs
│   │       ├── analyze_complexity.rs
│   │       ├── expand.rs
│   │       └── reanalyze_deps.rs
│   ├── models/
│   │   ├── task.rs
│   │   └── phase.rs
│   ├── storage/
│   │   └── mod.rs           # JSON I/O
│   └── llm/
│       ├── client.rs        # Anthropic API (text-in/text-out)
│       ├── prompts.rs       # Prompt templates
│       ├── oauth.rs         # [direct-api] OAuth token from Keychain
│       ├── tools.rs         # [direct-api] Tool definitions & execution
│       └── agent.rs         # [direct-api] Agentic loop engine
```

### Adding New Commands

1. Add command to `Commands` enum in `main.rs`
2. Create handler in `src/commands/`
3. Add module to `src/commands/mod.rs`
4. Update help text

### Adding New LLM Prompts

1. Add prompt function to `src/llm/prompts.rs`
2. Create command handler in `src/commands/ai/`
3. Use `LLMClient::complete()` or `complete_json()`

## Testing

```bash
# Build and test
cargo build
cargo test

# Test specific command
cargo run -- init
cargo run -- tags
cargo run -- --help

# Test AI commands (requires API key)
export ANTHROPIC_API_KEY=sk-...
cargo run -- parse-prd test.md --tag test
```

## Distribution

### As Standalone Binary

```bash
cargo build --release
# Binary: target/release/scud
# Copy to /usr/local/bin or similar
```

### Via npm Package

The npm package builds the Rust binary during installation:
- Runs `cargo build --release` during `npm install`
- Binary is placed in `bin/` directory
- `bin/scud.js` is a thin wrapper that executes the binary
- Requires Rust toolchain to be installed

## Cargo Features

| Feature | Description |
|---------|-------------|
| `direct-api` | Direct Anthropic API agentic runner (replaces `claude -p` harness) |
| `real-llm` | Enable tests that make real LLM API calls |
| `real-terminal` | Enable tests that use real terminal sessions (tmux/kitty) |
| `zmq` | Enable ZeroMQ event publishing |

## Future Enhancements

- [ ] Cross-compilation for multiple platforms
- [ ] Pre-built binaries in npm package (eliminate Rust requirement)
- [ ] Task export/import
- [ ] Custom prompt templates
- [ ] Integration tests with real API calls
- [ ] Streaming support for direct-api agentic loop

## License

MIT

## Contributing

See main SCUD repository for contribution guidelines.