claudish 1.8.0 → 2.0.0

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.
@@ -0,0 +1,534 @@
1
+ # Claudish AI Agent Usage Guide
2
+
3
+ **Version:** 1.0.0
4
+ **Target Audience:** AI Agents running within Claude Code
5
+ **Purpose:** Quick reference for using Claudish CLI in agentic workflows
6
+
7
+ ---
8
+
9
+ ## TL;DR - Quick Start
10
+
11
+ ```bash
12
+ # 1. Get available models
13
+ claudish --list-models --json
14
+
15
+ # 2. Run task with specific model
16
+ claudish --model x-ai/grok-code-fast-1 "your task here"
17
+
18
+ # 3. For large prompts, use stdin
19
+ echo "your task" | claudish --stdin --model x-ai/grok-code-fast-1
20
+ ```
21
+
22
+ ## What is Claudish?
23
+
24
+ Claudish = Claude Code + OpenRouter models
25
+
26
+ - ✅ Run Claude Code with **any OpenRouter model** (Grok, GPT-5, Gemini, MiniMax, etc.)
27
+ - ✅ 100% Claude Code feature compatibility
28
+ - ✅ Local proxy server (no data sent to Claudish servers)
29
+ - ✅ Cost tracking and model selection
30
+
31
+ ## Prerequisites
32
+
33
+ 1. **Install Claudish:**
34
+ ```bash
35
+ npm install -g claudish
36
+ ```
37
+
38
+ 2. **Set OpenRouter API Key:**
39
+ ```bash
40
+ export OPENROUTER_API_KEY='sk-or-v1-...'
41
+ ```
42
+
43
+ 3. **Optional but recommended:**
44
+ ```bash
45
+ export ANTHROPIC_API_KEY='sk-ant-api03-placeholder'
46
+ ```
47
+
48
+ ## Top Models for Development
49
+
50
+ | Model ID | Provider | Category | Best For |
51
+ |----------|----------|----------|----------|
52
+ | `x-ai/grok-code-fast-1` | xAI | Coding | Fast iterations, agentic coding |
53
+ | `google/gemini-2.5-flash` | Google | Reasoning | Complex analysis, 1000K context |
54
+ | `minimax/minimax-m2` | MiniMax | Coding | General coding tasks |
55
+ | `openai/gpt-5` | OpenAI | Reasoning | Architecture decisions |
56
+ | `qwen/qwen3-vl-235b-a22b-instruct` | Alibaba | Vision | UI/visual tasks |
57
+
58
+ **Update models:**
59
+ ```bash
60
+ claudish --list-models --force-update
61
+ ```
62
+
63
+ ## Critical: File-Based Pattern for Sub-Agents
64
+
65
+ ### ⚠️ Problem: Context Window Pollution
66
+
67
+ Running Claudish directly in main conversation pollutes context with:
68
+ - Entire conversation transcript
69
+ - All tool outputs
70
+ - Model reasoning (10K+ tokens)
71
+
72
+ ### ✅ Solution: File-Based Sub-Agent Pattern
73
+
74
+ **Pattern:**
75
+ 1. Write instructions to file
76
+ 2. Run Claudish with file input
77
+ 3. Read result from file
78
+ 4. Return summary only (not full output)
79
+
80
+ **Example:**
81
+ ```typescript
82
+ // Step 1: Write instruction file
83
+ const instructionFile = `/tmp/claudish-task-${Date.now()}.md`;
84
+ const resultFile = `/tmp/claudish-result-${Date.now()}.md`;
85
+
86
+ const instruction = `# Task
87
+ Implement user authentication
88
+
89
+ # Requirements
90
+ - JWT tokens
91
+ - bcrypt password hashing
92
+ - Protected route middleware
93
+
94
+ # Output
95
+ Write to: ${resultFile}
96
+ `;
97
+
98
+ await Write({ file_path: instructionFile, content: instruction });
99
+
100
+ // Step 2: Run Claudish
101
+ await Bash(`claudish --model x-ai/grok-code-fast-1 --stdin < ${instructionFile}`);
102
+
103
+ // Step 3: Read result
104
+ const result = await Read({ file_path: resultFile });
105
+
106
+ // Step 4: Return summary only
107
+ const summary = extractSummary(result);
108
+ return `✅ Completed. ${summary}`;
109
+
110
+ // Clean up
111
+ await Bash(`rm ${instructionFile} ${resultFile}`);
112
+ ```
113
+
114
+ ## Using Claudish in Sub-Agents
115
+
116
+ ### Method 1: Direct Bash Execution
117
+
118
+ ```typescript
119
+ // For simple tasks with short output
120
+ const { stdout } = await Bash("claudish --model x-ai/grok-code-fast-1 --json 'quick task'");
121
+ const result = JSON.parse(stdout);
122
+
123
+ // Return only essential info
124
+ return `Cost: $${result.total_cost_usd}, Result: ${result.result.substring(0, 100)}...`;
125
+ ```
126
+
127
+ ### Method 2: Task Tool Delegation
128
+
129
+ ```typescript
130
+ // For complex tasks requiring isolation
131
+ const result = await Task({
132
+ subagent_type: "general-purpose",
133
+ description: "Implement feature with Grok",
134
+ prompt: `
135
+ Use Claudish to implement feature with Grok model:
136
+
137
+ STEPS:
138
+ 1. Create instruction file at /tmp/claudish-instruction-${Date.now()}.md
139
+ 2. Write feature requirements to file
140
+ 3. Run: claudish --model x-ai/grok-code-fast-1 --stdin < /tmp/claudish-instruction-*.md
141
+ 4. Read result and return ONLY:
142
+ - Files modified (list)
143
+ - Brief summary (2-3 sentences)
144
+ - Cost (if available)
145
+
146
+ DO NOT return full implementation details.
147
+ Keep response under 300 tokens.
148
+ `
149
+ });
150
+ ```
151
+
152
+ ### Method 3: Multi-Model Comparison
153
+
154
+ ```typescript
155
+ // Compare results from multiple models
156
+ const models = [
157
+ "x-ai/grok-code-fast-1",
158
+ "google/gemini-2.5-flash",
159
+ "openai/gpt-5"
160
+ ];
161
+
162
+ for (const model of models) {
163
+ const result = await Bash(`claudish --model ${model} --json "analyze security"`);
164
+ const data = JSON.parse(result.stdout);
165
+
166
+ console.log(`${model}: $${data.total_cost_usd}`);
167
+ // Store results for comparison
168
+ }
169
+ ```
170
+
171
+ ## Essential CLI Flags
172
+
173
+ ### Core Flags
174
+
175
+ | Flag | Description | Example |
176
+ |------|-------------|---------|
177
+ | `--model <model>` | OpenRouter model to use | `--model x-ai/grok-code-fast-1` |
178
+ | `--stdin` | Read prompt from stdin | `cat task.md \| claudish --stdin --model grok` |
179
+ | `--json` | JSON output (structured) | `claudish --json "task"` |
180
+ | `--list-models` | List available models | `claudish --list-models --json` |
181
+
182
+ ### Useful Flags
183
+
184
+ | Flag | Description | Default |
185
+ |------|-------------|---------|
186
+ | `--quiet` / `-q` | Suppress logs | Enabled in single-shot |
187
+ | `--verbose` / `-v` | Show logs | Enabled in interactive |
188
+ | `--debug` / `-d` | Debug logging to file | Disabled |
189
+ | `--no-auto-approve` | Require prompts | Auto-approve enabled |
190
+
191
+ ## Common Workflows
192
+
193
+ ### Workflow 1: Quick Code Fix (Grok)
194
+
195
+ ```bash
196
+ # Fast coding with visible reasoning
197
+ claudish --model x-ai/grok-code-fast-1 "fix null pointer error in user.ts"
198
+ ```
199
+
200
+ ### Workflow 2: Complex Refactoring (GPT-5)
201
+
202
+ ```bash
203
+ # Advanced reasoning for architecture
204
+ claudish --model openai/gpt-5 "refactor to microservices architecture"
205
+ ```
206
+
207
+ ### Workflow 3: Code Review (Gemini)
208
+
209
+ ```bash
210
+ # Deep analysis with large context
211
+ git diff | claudish --stdin --model google/gemini-2.5-flash "review for bugs"
212
+ ```
213
+
214
+ ### Workflow 4: UI Implementation (Qwen Vision)
215
+
216
+ ```bash
217
+ # Vision model for visual tasks
218
+ claudish --model qwen/qwen3-vl-235b-a22b-instruct "implement dashboard from design"
219
+ ```
220
+
221
+ ## Getting Model List
222
+
223
+ ### JSON Output (Recommended)
224
+
225
+ ```bash
226
+ claudish --list-models --json
227
+ ```
228
+
229
+ **Output:**
230
+ ```json
231
+ {
232
+ "version": "1.8.0",
233
+ "lastUpdated": "2025-11-19",
234
+ "source": "https://openrouter.ai/models",
235
+ "models": [
236
+ {
237
+ "id": "x-ai/grok-code-fast-1",
238
+ "name": "Grok Code Fast 1",
239
+ "description": "Ultra-fast agentic coding",
240
+ "provider": "xAI",
241
+ "category": "coding",
242
+ "priority": 1,
243
+ "pricing": {
244
+ "input": "$0.20/1M",
245
+ "output": "$1.50/1M",
246
+ "average": "$0.85/1M"
247
+ },
248
+ "context": "256K",
249
+ "supportsTools": true,
250
+ "supportsReasoning": true
251
+ }
252
+ ]
253
+ }
254
+ ```
255
+
256
+ ### Parse in TypeScript
257
+
258
+ ```typescript
259
+ const { stdout } = await Bash("claudish --list-models --json");
260
+ const data = JSON.parse(stdout);
261
+
262
+ // Get all model IDs
263
+ const modelIds = data.models.map(m => m.id);
264
+
265
+ // Get coding models
266
+ const codingModels = data.models.filter(m => m.category === "coding");
267
+
268
+ // Get cheapest model
269
+ const cheapest = data.models.sort((a, b) =>
270
+ parseFloat(a.pricing.average) - parseFloat(b.pricing.average)
271
+ )[0];
272
+ ```
273
+
274
+ ## JSON Output Format
275
+
276
+ When using `--json` flag, Claudish returns:
277
+
278
+ ```json
279
+ {
280
+ "result": "AI response text",
281
+ "total_cost_usd": 0.068,
282
+ "usage": {
283
+ "input_tokens": 1234,
284
+ "output_tokens": 5678
285
+ },
286
+ "duration_ms": 12345,
287
+ "num_turns": 3,
288
+ "modelUsage": {
289
+ "x-ai/grok-code-fast-1": {
290
+ "inputTokens": 1234,
291
+ "outputTokens": 5678
292
+ }
293
+ }
294
+ }
295
+ ```
296
+
297
+ **Extract fields:**
298
+ ```bash
299
+ claudish --json "task" | jq -r '.result' # Get result text
300
+ claudish --json "task" | jq -r '.total_cost_usd' # Get cost
301
+ claudish --json "task" | jq -r '.usage' # Get token usage
302
+ ```
303
+
304
+ ## Error Handling
305
+
306
+ ### Check Claudish Installation
307
+
308
+ ```typescript
309
+ try {
310
+ await Bash("which claudish");
311
+ } catch (error) {
312
+ console.error("Claudish not installed. Install with: npm install -g claudish");
313
+ // Use fallback (embedded Claude models)
314
+ }
315
+ ```
316
+
317
+ ### Check API Key
318
+
319
+ ```typescript
320
+ const apiKey = process.env.OPENROUTER_API_KEY;
321
+ if (!apiKey) {
322
+ console.error("OPENROUTER_API_KEY not set. Get key at: https://openrouter.ai/keys");
323
+ // Use fallback
324
+ }
325
+ ```
326
+
327
+ ### Handle Model Errors
328
+
329
+ ```typescript
330
+ try {
331
+ const result = await Bash("claudish --model x-ai/grok-code-fast-1 'task'");
332
+ } catch (error) {
333
+ if (error.message.includes("Model not found")) {
334
+ console.error("Model unavailable. Listing alternatives...");
335
+ await Bash("claudish --list-models");
336
+ } else {
337
+ console.error("Claudish error:", error.message);
338
+ }
339
+ }
340
+ ```
341
+
342
+ ### Graceful Fallback
343
+
344
+ ```typescript
345
+ async function runWithClaudishOrFallback(task: string) {
346
+ try {
347
+ // Try Claudish with Grok
348
+ const result = await Bash(`claudish --model x-ai/grok-code-fast-1 "${task}"`);
349
+ return result.stdout;
350
+ } catch (error) {
351
+ console.warn("Claudish unavailable, using embedded Claude");
352
+ // Run with standard Claude Code
353
+ return await runWithEmbeddedClaude(task);
354
+ }
355
+ }
356
+ ```
357
+
358
+ ## Cost Tracking
359
+
360
+ ### View Cost in Status Line
361
+
362
+ Claudish shows cost in Claude Code status line:
363
+ ```
364
+ directory • x-ai/grok-code-fast-1 • $0.12 • 67%
365
+ ```
366
+
367
+ ### Get Cost from JSON
368
+
369
+ ```bash
370
+ COST=$(claudish --json "task" | jq -r '.total_cost_usd')
371
+ echo "Task cost: \$${COST}"
372
+ ```
373
+
374
+ ### Track Cumulative Costs
375
+
376
+ ```typescript
377
+ let totalCost = 0;
378
+
379
+ for (const task of tasks) {
380
+ const result = await Bash(`claudish --json --model grok "${task}"`);
381
+ const data = JSON.parse(result.stdout);
382
+ totalCost += data.total_cost_usd;
383
+ }
384
+
385
+ console.log(`Total cost: $${totalCost.toFixed(4)}`);
386
+ ```
387
+
388
+ ## Best Practices Summary
389
+
390
+ ### ✅ DO
391
+
392
+ 1. **Use file-based pattern** for sub-agents to avoid context pollution
393
+ 2. **Choose appropriate model** for task (Grok=speed, GPT-5=reasoning, Qwen=vision)
394
+ 3. **Use --json output** for automation and parsing
395
+ 4. **Handle errors gracefully** with fallbacks
396
+ 5. **Track costs** when running multiple tasks
397
+ 6. **Update models regularly** with `--force-update`
398
+ 7. **Use --stdin** for large prompts (git diffs, code review)
399
+
400
+ ### ❌ DON'T
401
+
402
+ 1. **Don't run Claudish directly** in main conversation (pollutes context)
403
+ 2. **Don't ignore model selection** (different models have different strengths)
404
+ 3. **Don't parse text output** (use --json instead)
405
+ 4. **Don't hardcode model lists** (query dynamically)
406
+ 5. **Don't skip error handling** (Claudish might not be installed)
407
+ 6. **Don't return full output** in sub-agents (summary only)
408
+
409
+ ## Quick Reference Commands
410
+
411
+ ```bash
412
+ # Installation
413
+ npm install -g claudish
414
+
415
+ # Get models
416
+ claudish --list-models --json
417
+
418
+ # Run task
419
+ claudish --model x-ai/grok-code-fast-1 "your task"
420
+
421
+ # Large prompt
422
+ git diff | claudish --stdin --model google/gemini-2.5-flash "review"
423
+
424
+ # JSON output
425
+ claudish --json --model grok "task" | jq -r '.total_cost_usd'
426
+
427
+ # Update models
428
+ claudish --list-models --force-update
429
+
430
+ # Get help
431
+ claudish --help
432
+ ```
433
+
434
+ ## Example: Complete Sub-Agent Implementation
435
+
436
+ ```typescript
437
+ /**
438
+ * Example: Implement feature with Claudish + Grok
439
+ * Returns summary only, full implementation in file
440
+ */
441
+ async function implementFeatureWithGrok(description: string): Promise<string> {
442
+ const timestamp = Date.now();
443
+ const instructionFile = `/tmp/claudish-implement-${timestamp}.md`;
444
+ const resultFile = `/tmp/claudish-result-${timestamp}.md`;
445
+
446
+ try {
447
+ // 1. Create instruction
448
+ const instruction = `# Feature Implementation
449
+
450
+ ## Description
451
+ ${description}
452
+
453
+ ## Requirements
454
+ - Clean, maintainable code
455
+ - Comprehensive tests
456
+ - Error handling
457
+ - Documentation
458
+
459
+ ## Output File
460
+ ${resultFile}
461
+
462
+ ## Format
463
+ \`\`\`markdown
464
+ ## Files Modified
465
+ - path/to/file1.ts
466
+ - path/to/file2.ts
467
+
468
+ ## Summary
469
+ [2-3 sentence summary]
470
+
471
+ ## Tests Added
472
+ - test description 1
473
+ - test description 2
474
+ \`\`\`
475
+ `;
476
+
477
+ await Write({ file_path: instructionFile, content: instruction });
478
+
479
+ // 2. Run Claudish
480
+ await Bash(`claudish --model x-ai/grok-code-fast-1 --stdin < ${instructionFile}`);
481
+
482
+ // 3. Read result
483
+ const result = await Read({ file_path: resultFile });
484
+
485
+ // 4. Extract summary
486
+ const filesMatch = result.match(/## Files Modified\s*\n(.*?)(?=\n##|$)/s);
487
+ const files = filesMatch ? filesMatch[1].trim().split('\n').length : 0;
488
+
489
+ const summaryMatch = result.match(/## Summary\s*\n(.*?)(?=\n##|$)/s);
490
+ const summary = summaryMatch ? summaryMatch[1].trim() : "Implementation completed";
491
+
492
+ // 5. Clean up
493
+ await Bash(`rm ${instructionFile} ${resultFile}`);
494
+
495
+ // 6. Return concise summary
496
+ return `✅ Feature implemented. Modified ${files} files. ${summary}`;
497
+
498
+ } catch (error) {
499
+ // 7. Handle errors
500
+ console.error("Claudish implementation failed:", error.message);
501
+
502
+ // Clean up if files exist
503
+ try {
504
+ await Bash(`rm -f ${instructionFile} ${resultFile}`);
505
+ } catch {}
506
+
507
+ return `❌ Implementation failed: ${error.message}`;
508
+ }
509
+ }
510
+ ```
511
+
512
+ ## Additional Resources
513
+
514
+ - **Full Documentation:** `<claudish-install-path>/README.md`
515
+ - **Skill Document:** `/Users/jack/mag/claude-code/skills/claudish-usage/SKILL.md`
516
+ - **Model Integration:** `/Users/jack/mag/claude-code/skills/claudish-integration/SKILL.md`
517
+ - **OpenRouter Docs:** https://openrouter.ai/docs
518
+ - **Claudish GitHub:** https://github.com/MadAppGang/claude-code
519
+
520
+ ## Get This Guide
521
+
522
+ ```bash
523
+ # Print this guide
524
+ claudish --help-ai
525
+
526
+ # Save to file
527
+ claudish --help-ai > claudish-agent-guide.md
528
+ ```
529
+
530
+ ---
531
+
532
+ **Version:** 1.0.0
533
+ **Last Updated:** November 19, 2025
534
+ **Maintained by:** MadAppGang
package/README.md CHANGED
@@ -66,6 +66,29 @@ bun link # or: npm link
66
66
 
67
67
  ## Quick Start
68
68
 
69
+ ### Step 0: Initialize Claudish Skill (First Time Only)
70
+
71
+ ```bash
72
+ # Navigate to your project directory
73
+ cd /path/to/your/project
74
+
75
+ # Install Claudish skill for automatic best practices
76
+ claudish --init
77
+
78
+ # Reload Claude Code to discover the skill
79
+ ```
80
+
81
+ **What this does:**
82
+ - ✅ Installs Claudish usage skill in `.claude/skills/claudish-usage/`
83
+ - ✅ Enables automatic sub-agent delegation
84
+ - ✅ Enforces file-based instruction patterns
85
+ - ✅ Prevents context window pollution
86
+
87
+ **After running --init**, Claude will automatically:
88
+ - Use sub-agents when you mention external models (Grok, GPT-5, etc.)
89
+ - Follow best practices for Claudish usage
90
+ - Suggest specialized agents for different tasks
91
+
69
92
  ### Option 1: Interactive Mode (Easiest)
70
93
 
71
94
  ```bash
@@ -93,6 +116,83 @@ claudish --model openai/gpt-5-codex "add tests"
93
116
 
94
117
  **Note:** In interactive mode, if `OPENROUTER_API_KEY` is not set, you'll be prompted to enter it. This makes first-time usage super simple!
95
118
 
119
+ ## AI Agent Usage
120
+
121
+ **For AI agents running within Claude Code:** Use the dedicated AI agent guide for comprehensive instructions on file-based patterns and sub-agent delegation.
122
+
123
+ ```bash
124
+ # Print complete AI agent usage guide
125
+ claudish --help-ai
126
+
127
+ # Save guide to file for reference
128
+ claudish --help-ai > claudish-agent-guide.md
129
+ ```
130
+
131
+ **Quick Reference for AI Agents:**
132
+
133
+ ### Main Workflow for AI Agents
134
+
135
+ 1. **Get available models:**
136
+ ```bash
137
+ claudish --list-models --json
138
+ ```
139
+
140
+ 2. **Run Claudish through sub-agent** (recommended pattern):
141
+ ```typescript
142
+ // Don't run Claudish directly in main conversation
143
+ // Use Task tool to delegate to sub-agent
144
+ const result = await Task({
145
+ subagent_type: "general-purpose",
146
+ description: "Implement feature with Grok",
147
+ prompt: `
148
+ Use Claudish to implement feature with Grok model.
149
+
150
+ STEPS:
151
+ 1. Create instruction file: /tmp/claudish-task-${Date.now()}.md
152
+ 2. Write feature requirements to file
153
+ 3. Run: claudish --model x-ai/grok-code-fast-1 --stdin < /tmp/claudish-task-*.md
154
+ 4. Read result and return ONLY summary (2-3 sentences)
155
+
156
+ DO NOT return full implementation. Keep response under 300 tokens.
157
+ `
158
+ });
159
+ ```
160
+
161
+ 3. **File-based instruction pattern** (avoids context pollution):
162
+ ```typescript
163
+ // Write instructions to file
164
+ const instructionFile = `/tmp/claudish-task-${Date.now()}.md`;
165
+ const resultFile = `/tmp/claudish-result-${Date.now()}.md`;
166
+
167
+ await Write({ file_path: instructionFile, content: `
168
+ # Task
169
+ Your task description here
170
+
171
+ # Output
172
+ Write results to: ${resultFile}
173
+ ` });
174
+
175
+ // Run Claudish with stdin
176
+ await Bash(`claudish --model x-ai/grok-code-fast-1 --stdin < ${instructionFile}`);
177
+
178
+ // Read result
179
+ const result = await Read({ file_path: resultFile });
180
+
181
+ // Return summary only
182
+ return extractSummary(result);
183
+ ```
184
+
185
+ **Key Principles:**
186
+ - ✅ Use file-based patterns to avoid context window pollution
187
+ - ✅ Delegate to sub-agents instead of running directly
188
+ - ✅ Return summaries only (not full conversation transcripts)
189
+ - ✅ Choose appropriate model for task (see `--list-models`)
190
+
191
+ **Resources:**
192
+ - Full AI agent guide: `claudish --help-ai`
193
+ - Skill document: `/Users/jack/mag/claude-code/skills/claudish-usage/SKILL.md`
194
+ - Model integration: `/Users/jack/mag/claude-code/skills/claudish-integration/SKILL.md`
195
+
96
196
  ## Usage
97
197
 
98
198
  ### Basic Syntax
@@ -115,6 +215,8 @@ claudish [OPTIONS] <claude-args...>
115
215
  | `--no-auto-approve` | Disable auto-approve (require prompts) | Auto-approve **enabled** |
116
216
  | `--dangerous` | Pass `--dangerouslyDisableSandbox` | `false` |
117
217
  | `--list-models` | List available models | - |
218
+ | `--init` | Install Claudish skill in current project | - |
219
+ | `--help-ai` | Show AI agent usage guide | - |
118
220
  | `-h, --help` | Show help message | - |
119
221
 
120
222
  ### Environment Variables