claudish 1.7.1 → 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,1127 @@
1
+ ---
2
+ name: claudish-usage
3
+ description: CRITICAL - Guide for using Claudish CLI ONLY through sub-agents to run Claude Code with OpenRouter models (Grok, GPT-5, Gemini, MiniMax). NEVER run Claudish directly in main context unless user explicitly requests it. Use when user mentions external AI models, Claudish, OpenRouter, or alternative models. Includes mandatory sub-agent delegation patterns, agent selection guide, file-based instructions, and strict rules to prevent context window pollution.
4
+ ---
5
+
6
+ # Claudish Usage Skill
7
+
8
+ **Version:** 1.0.0
9
+ **Purpose:** Guide AI agents on how to use Claudish CLI to run Claude Code with OpenRouter models
10
+ **Status:** Production Ready
11
+
12
+ ## ⚠️ CRITICAL RULES - READ FIRST
13
+
14
+ ### 🚫 NEVER Run Claudish from Main Context
15
+
16
+ **Claudish MUST ONLY be run through sub-agents** unless the user **explicitly** requests direct execution.
17
+
18
+ **Why:**
19
+ - Running Claudish directly pollutes main context with 10K+ tokens (full conversation + reasoning)
20
+ - Destroys context window efficiency
21
+ - Makes main conversation unmanageable
22
+
23
+ **When you can run Claudish directly:**
24
+ - ✅ User explicitly says "run claudish directly" or "don't use a sub-agent"
25
+ - ✅ User is debugging and wants to see full output
26
+ - ✅ User specifically requests main context execution
27
+
28
+ **When you MUST use sub-agent:**
29
+ - ✅ User says "use Grok to implement X" (delegate to sub-agent)
30
+ - ✅ User says "ask GPT-5 to review X" (delegate to sub-agent)
31
+ - ✅ User mentions any model name without "directly" (delegate to sub-agent)
32
+ - ✅ Any production task (always delegate)
33
+
34
+ ### 📋 Workflow Decision Tree
35
+
36
+ ```
37
+ User Request
38
+
39
+ Does it mention Claudish/OpenRouter/model name? → NO → Don't use this skill
40
+ ↓ YES
41
+
42
+ Does user say "directly" or "in main context"? → YES → Run in main context (rare)
43
+ ↓ NO
44
+
45
+ Find appropriate agent or create one → Delegate to sub-agent (default)
46
+ ```
47
+
48
+ ## 🤖 Agent Selection Guide
49
+
50
+ ### Step 1: Find the Right Agent
51
+
52
+ **When user requests Claudish task, follow this process:**
53
+
54
+ 1. **Check for existing agents** that support proxy mode or external model delegation
55
+ 2. **If no suitable agent exists:**
56
+ - Suggest creating a new proxy-mode agent for this task type
57
+ - Offer to proceed with generic `general-purpose` agent if user declines
58
+ 3. **If user declines agent creation:**
59
+ - Warn about context pollution
60
+ - Ask if they want to proceed anyway
61
+
62
+ ### Step 2: Agent Type Selection Matrix
63
+
64
+ | Task Type | Recommended Agent | Fallback | Notes |
65
+ |-----------|------------------|----------|-------|
66
+ | **Code implementation** | Create coding agent with proxy mode | `general-purpose` | Best: custom agent for project-specific patterns |
67
+ | **Code review** | Use existing code review agent + proxy | `general-purpose` | Check if plugin has review agent first |
68
+ | **Architecture planning** | Use existing architect agent + proxy | `general-purpose` | Look for `architect` or `planner` agents |
69
+ | **Testing** | Use existing test agent + proxy | `general-purpose` | Look for `test-architect` or `tester` agents |
70
+ | **Refactoring** | Create refactoring agent with proxy | `general-purpose` | Complex refactors benefit from specialized agent |
71
+ | **Documentation** | `general-purpose` | - | Simple task, generic agent OK |
72
+ | **Analysis** | Use existing analysis agent + proxy | `general-purpose` | Check for `analyzer` or `detective` agents |
73
+ | **Other** | `general-purpose` | - | Default for unknown task types |
74
+
75
+ ### Step 3: Agent Creation Offer (When No Agent Exists)
76
+
77
+ **Template response:**
78
+ ```
79
+ I notice you want to use [Model Name] for [task type].
80
+
81
+ RECOMMENDATION: Create a specialized [task type] agent with proxy mode support.
82
+
83
+ This would:
84
+ ✅ Provide better task-specific guidance
85
+ ✅ Reusable for future [task type] tasks
86
+ ✅ Optimized prompting for [Model Name]
87
+
88
+ Options:
89
+ 1. Create specialized agent (recommended) - takes 2-3 minutes
90
+ 2. Use generic general-purpose agent - works but less optimized
91
+ 3. Run directly in main context (NOT recommended - pollutes context)
92
+
93
+ Which would you prefer?
94
+ ```
95
+
96
+ ### Step 4: Common Agents by Plugin
97
+
98
+ **Frontend Plugin:**
99
+ - `typescript-frontend-dev` - Use for UI implementation with external models
100
+ - `frontend-architect` - Use for architecture planning with external models
101
+ - `senior-code-reviewer` - Use for code review (can delegate to external models)
102
+ - `test-architect` - Use for test planning/implementation
103
+
104
+ **Bun Backend Plugin:**
105
+ - `backend-developer` - Use for API implementation with external models
106
+ - `api-architect` - Use for API design with external models
107
+
108
+ **Code Analysis Plugin:**
109
+ - `codebase-detective` - Use for investigation tasks with external models
110
+
111
+ **No Plugin:**
112
+ - `general-purpose` - Default fallback for any task
113
+
114
+ ### Step 5: Example Agent Selection
115
+
116
+ **Example 1: User says "use Grok to implement authentication"**
117
+ ```
118
+ Task: Code implementation (authentication)
119
+ Plugin: Bun Backend (if backend) or Frontend (if UI)
120
+
121
+ Decision:
122
+ 1. Check for backend-developer or typescript-frontend-dev agent
123
+ 2. Found backend-developer? → Use it with Grok proxy
124
+ 3. Not found? → Offer to create custom auth agent
125
+ 4. User declines? → Use general-purpose with file-based pattern
126
+ ```
127
+
128
+ **Example 2: User says "ask GPT-5 to review my API design"**
129
+ ```
130
+ Task: Code review (API design)
131
+ Plugin: Bun Backend
132
+
133
+ Decision:
134
+ 1. Check for api-architect or senior-code-reviewer agent
135
+ 2. Found? → Use it with GPT-5 proxy
136
+ 3. Not found? → Use general-purpose with review instructions
137
+ 4. Never run directly in main context
138
+ ```
139
+
140
+ **Example 3: User says "use Gemini to refactor this component"**
141
+ ```
142
+ Task: Refactoring (component)
143
+ Plugin: Frontend
144
+
145
+ Decision:
146
+ 1. No specialized refactoring agent exists
147
+ 2. Offer to create component-refactoring agent
148
+ 3. User declines? → Use typescript-frontend-dev with proxy
149
+ 4. Still no agent? → Use general-purpose with file-based pattern
150
+ ```
151
+
152
+ ## Overview
153
+
154
+ **Claudish** is a CLI tool that allows running Claude Code with any OpenRouter model (Grok, GPT-5, MiniMax, Gemini, etc.) by proxying requests through a local Anthropic API-compatible server.
155
+
156
+ **Key Principle:** **ALWAYS** use Claudish through sub-agents with file-based instructions to avoid context window pollution.
157
+
158
+ ## What is Claudish?
159
+
160
+ Claudish (Claude-ish) is a proxy tool that:
161
+ - ✅ Runs Claude Code with **any OpenRouter model** (not just Anthropic models)
162
+ - ✅ Uses local API-compatible proxy server
163
+ - ✅ Supports 100% of Claude Code features
164
+ - ✅ Provides cost tracking and model selection
165
+ - ✅ Enables multi-model workflows
166
+
167
+ **Use Cases:**
168
+ - Run tasks with different AI models (Grok for speed, GPT-5 for reasoning, Gemini for vision)
169
+ - Compare model performance on same task
170
+ - Reduce costs with cheaper models for simple tasks
171
+ - Access models with specialized capabilities
172
+
173
+ ## Requirements
174
+
175
+ ### System Requirements
176
+ - **OpenRouter API Key** - Required (set as `OPENROUTER_API_KEY` environment variable)
177
+ - **Claudish CLI** - Install with: `npm install -g claudish` or `bun install -g claudish`
178
+ - **Claude Code** - Must be installed
179
+
180
+ ### Environment Variables
181
+
182
+ ```bash
183
+ # Required
184
+ export OPENROUTER_API_KEY='sk-or-v1-...' # Your OpenRouter API key
185
+
186
+ # Optional (but recommended)
187
+ export ANTHROPIC_API_KEY='sk-ant-api03-placeholder' # Prevents Claude Code dialog
188
+
189
+ # Optional - default model
190
+ export CLAUDISH_MODEL='x-ai/grok-code-fast-1' # or ANTHROPIC_MODEL
191
+ ```
192
+
193
+ **Get OpenRouter API Key:**
194
+ 1. Visit https://openrouter.ai/keys
195
+ 2. Sign up (free tier available)
196
+ 3. Create API key
197
+ 4. Set as environment variable
198
+
199
+ ## Quick Start Guide
200
+
201
+ ### Step 1: Install Claudish
202
+
203
+ ```bash
204
+ # With npm (works everywhere)
205
+ npm install -g claudish
206
+
207
+ # With Bun (faster)
208
+ bun install -g claudish
209
+
210
+ # Verify installation
211
+ claudish --version
212
+ ```
213
+
214
+ ### Step 2: Get Available Models
215
+
216
+ ```bash
217
+ # List all available models (auto-updates if cache >2 days old)
218
+ claudish --list-models
219
+
220
+ # JSON output for parsing
221
+ claudish --list-models --json
222
+
223
+ # Force update from OpenRouter API
224
+ claudish --list-models --force-update
225
+ ```
226
+
227
+ ### Step 3: Run Claudish
228
+
229
+ **Interactive Mode (default):**
230
+ ```bash
231
+ # Shows model selector, persistent session
232
+ claudish
233
+ ```
234
+
235
+ **Single-shot Mode:**
236
+ ```bash
237
+ # One task and exit (requires --model)
238
+ claudish --model x-ai/grok-code-fast-1 "implement user authentication"
239
+ ```
240
+
241
+ **With stdin for large prompts:**
242
+ ```bash
243
+ # Read prompt from stdin (useful for git diffs, code review)
244
+ git diff | claudish --stdin --model openai/gpt-5-codex "Review these changes"
245
+ ```
246
+
247
+ ## Recommended Models
248
+
249
+ **Top Models for Development (verified from OpenRouter):**
250
+
251
+ 1. **x-ai/grok-code-fast-1** - xAI's Grok (fast coding, visible reasoning)
252
+ - Category: coding
253
+ - Context: 256K
254
+ - Best for: Quick iterations, agentic coding
255
+
256
+ 2. **google/gemini-2.5-flash** - Google's Gemini (state-of-the-art reasoning)
257
+ - Category: reasoning
258
+ - Context: 1000K
259
+ - Best for: Complex analysis, multi-step reasoning
260
+
261
+ 3. **minimax/minimax-m2** - MiniMax M2 (high performance)
262
+ - Category: coding
263
+ - Context: 128K
264
+ - Best for: General coding tasks
265
+
266
+ 4. **openai/gpt-5** - OpenAI's GPT-5 (advanced reasoning)
267
+ - Category: reasoning
268
+ - Context: 128K
269
+ - Best for: Complex implementations, architecture decisions
270
+
271
+ 5. **qwen/qwen3-vl-235b-a22b-instruct** - Alibaba's Qwen (vision-language)
272
+ - Category: vision
273
+ - Context: 32K
274
+ - Best for: UI/visual tasks, design implementation
275
+
276
+ **Get Latest Models:**
277
+ ```bash
278
+ # Auto-updates every 2 days
279
+ claudish --list-models
280
+
281
+ # Force immediate update
282
+ claudish --list-models --force-update
283
+ ```
284
+
285
+ ## Best Practice: File-Based Sub-Agent Pattern
286
+
287
+ ### ⚠️ CRITICAL: Don't Run Claudish Directly from Main Conversation
288
+
289
+ **Why:** Running Claudish directly in main conversation pollutes context window with:
290
+ - Entire conversation transcript
291
+ - All tool outputs
292
+ - Model reasoning (can be 10K+ tokens)
293
+
294
+ **Solution:** Use file-based sub-agent pattern
295
+
296
+ ### File-Based Pattern (Recommended)
297
+
298
+ **Step 1: Create instruction file**
299
+ ```markdown
300
+ # /tmp/claudish-task-{timestamp}.md
301
+
302
+ ## Task
303
+ Implement user authentication with JWT tokens
304
+
305
+ ## Requirements
306
+ - Use bcrypt for password hashing
307
+ - Generate JWT with 24h expiration
308
+ - Add middleware for protected routes
309
+
310
+ ## Deliverables
311
+ Write implementation to: /tmp/claudish-result-{timestamp}.md
312
+
313
+ ## Output Format
314
+ ```markdown
315
+ ## Implementation
316
+
317
+ [code here]
318
+
319
+ ## Files Created/Modified
320
+ - path/to/file1.ts
321
+ - path/to/file2.ts
322
+
323
+ ## Tests
324
+ [test code if applicable]
325
+
326
+ ## Notes
327
+ [any important notes]
328
+ ```
329
+ ```
330
+
331
+ **Step 2: Run Claudish with file instruction**
332
+ ```bash
333
+ # Read instruction from file, write result to file
334
+ claudish --model x-ai/grok-code-fast-1 --stdin < /tmp/claudish-task-{timestamp}.md > /tmp/claudish-result-{timestamp}.md
335
+ ```
336
+
337
+ **Step 3: Read result file and provide summary**
338
+ ```typescript
339
+ // In your agent/command:
340
+ const result = await Read({ file_path: "/tmp/claudish-result-{timestamp}.md" });
341
+
342
+ // Parse result
343
+ const filesModified = extractFilesModified(result);
344
+ const summary = extractSummary(result);
345
+
346
+ // Provide short feedback to main agent
347
+ return `✅ Task completed. Modified ${filesModified.length} files. ${summary}`;
348
+ ```
349
+
350
+ ### Complete Example: Using Claudish in Sub-Agent
351
+
352
+ ```typescript
353
+ /**
354
+ * Example: Run code review with Grok via Claudish sub-agent
355
+ */
356
+ async function runCodeReviewWithGrok(files: string[]) {
357
+ const timestamp = Date.now();
358
+ const instructionFile = `/tmp/claudish-review-instruction-${timestamp}.md`;
359
+ const resultFile = `/tmp/claudish-review-result-${timestamp}.md`;
360
+
361
+ // Step 1: Create instruction file
362
+ const instruction = `# Code Review Task
363
+
364
+ ## Files to Review
365
+ ${files.map(f => `- ${f}`).join('\n')}
366
+
367
+ ## Review Criteria
368
+ - Code quality and maintainability
369
+ - Potential bugs or issues
370
+ - Performance considerations
371
+ - Security vulnerabilities
372
+
373
+ ## Output Format
374
+ Write your review to: ${resultFile}
375
+
376
+ Use this format:
377
+ \`\`\`markdown
378
+ ## Summary
379
+ [Brief overview]
380
+
381
+ ## Issues Found
382
+ ### Critical
383
+ - [issue 1]
384
+
385
+ ### Medium
386
+ - [issue 2]
387
+
388
+ ### Low
389
+ - [issue 3]
390
+
391
+ ## Recommendations
392
+ - [recommendation 1]
393
+
394
+ ## Files Reviewed
395
+ - [file 1]: [status]
396
+ \`\`\`
397
+ `;
398
+
399
+ await Write({ file_path: instructionFile, content: instruction });
400
+
401
+ // Step 2: Run Claudish with stdin
402
+ await Bash(`claudish --model x-ai/grok-code-fast-1 --stdin < ${instructionFile}`);
403
+
404
+ // Step 3: Read result
405
+ const result = await Read({ file_path: resultFile });
406
+
407
+ // Step 4: Parse and return summary
408
+ const summary = extractSummary(result);
409
+ const issueCount = extractIssueCount(result);
410
+
411
+ // Step 5: Clean up temp files
412
+ await Bash(`rm ${instructionFile} ${resultFile}`);
413
+
414
+ // Step 6: Return concise feedback
415
+ return {
416
+ success: true,
417
+ summary,
418
+ issueCount,
419
+ fullReview: result // Available if needed, but not in main context
420
+ };
421
+ }
422
+
423
+ function extractSummary(review: string): string {
424
+ const match = review.match(/## Summary\s*\n(.*?)(?=\n##|$)/s);
425
+ return match ? match[1].trim() : "Review completed";
426
+ }
427
+
428
+ function extractIssueCount(review: string): { critical: number; medium: number; low: number } {
429
+ const critical = (review.match(/### Critical\s*\n(.*?)(?=\n###|$)/s)?.[1].match(/^-/gm) || []).length;
430
+ const medium = (review.match(/### Medium\s*\n(.*?)(?=\n###|$)/s)?.[1].match(/^-/gm) || []).length;
431
+ const low = (review.match(/### Low\s*\n(.*?)(?=\n###|$)/s)?.[1].match(/^-/gm) || []).length;
432
+
433
+ return { critical, medium, low };
434
+ }
435
+ ```
436
+
437
+ ## Sub-Agent Delegation Pattern
438
+
439
+ When running Claudish from an agent, use the Task tool to create a sub-agent:
440
+
441
+ ### Pattern 1: Simple Task Delegation
442
+
443
+ ```typescript
444
+ /**
445
+ * Example: Delegate implementation to Grok via Claudish
446
+ */
447
+ async function implementFeatureWithGrok(featureDescription: string) {
448
+ // Use Task tool to create sub-agent
449
+ const result = await Task({
450
+ subagent_type: "general-purpose",
451
+ description: "Implement feature with Grok",
452
+ prompt: `
453
+ Use Claudish CLI to implement this feature with Grok model:
454
+
455
+ ${featureDescription}
456
+
457
+ INSTRUCTIONS:
458
+ 1. First, get list of available models:
459
+ claudish --list-models
460
+
461
+ 2. Run implementation with Grok:
462
+ claudish --model x-ai/grok-code-fast-1 "${featureDescription}"
463
+
464
+ 3. Return ONLY:
465
+ - List of files created/modified
466
+ - Brief summary (2-3 sentences)
467
+ - Any errors encountered
468
+
469
+ DO NOT return the full conversation transcript or implementation details.
470
+ Keep your response under 500 tokens.
471
+ `
472
+ });
473
+
474
+ return result;
475
+ }
476
+ ```
477
+
478
+ ### Pattern 2: File-Based Task Delegation
479
+
480
+ ```typescript
481
+ /**
482
+ * Example: Use file-based instruction pattern in sub-agent
483
+ */
484
+ async function analyzeCodeWithGemini(codebasePath: string) {
485
+ const timestamp = Date.now();
486
+ const instructionFile = `/tmp/claudish-analyze-${timestamp}.md`;
487
+ const resultFile = `/tmp/claudish-analyze-result-${timestamp}.md`;
488
+
489
+ // Create instruction file
490
+ const instruction = `# Codebase Analysis Task
491
+
492
+ ## Codebase Path
493
+ ${codebasePath}
494
+
495
+ ## Analysis Required
496
+ - Architecture overview
497
+ - Key patterns used
498
+ - Potential improvements
499
+ - Security considerations
500
+
501
+ ## Output
502
+ Write analysis to: ${resultFile}
503
+
504
+ Keep analysis concise (under 1000 words).
505
+ `;
506
+
507
+ await Write({ file_path: instructionFile, content: instruction });
508
+
509
+ // Delegate to sub-agent
510
+ const result = await Task({
511
+ subagent_type: "general-purpose",
512
+ description: "Analyze codebase with Gemini",
513
+ prompt: `
514
+ Use Claudish to analyze codebase with Gemini model.
515
+
516
+ Instruction file: ${instructionFile}
517
+ Result file: ${resultFile}
518
+
519
+ STEPS:
520
+ 1. Read instruction file: ${instructionFile}
521
+ 2. Run: claudish --model google/gemini-2.5-flash --stdin < ${instructionFile}
522
+ 3. Wait for completion
523
+ 4. Read result file: ${resultFile}
524
+ 5. Return ONLY a 2-3 sentence summary
525
+
526
+ DO NOT include the full analysis in your response.
527
+ The full analysis is in ${resultFile} if needed.
528
+ `
529
+ });
530
+
531
+ // Read full result if needed
532
+ const fullAnalysis = await Read({ file_path: resultFile });
533
+
534
+ // Clean up
535
+ await Bash(`rm ${instructionFile} ${resultFile}`);
536
+
537
+ return {
538
+ summary: result,
539
+ fullAnalysis
540
+ };
541
+ }
542
+ ```
543
+
544
+ ### Pattern 3: Multi-Model Comparison
545
+
546
+ ```typescript
547
+ /**
548
+ * Example: Run same task with multiple models and compare
549
+ */
550
+ async function compareModels(task: string, models: string[]) {
551
+ const results = [];
552
+
553
+ for (const model of models) {
554
+ const timestamp = Date.now();
555
+ const resultFile = `/tmp/claudish-${model.replace('/', '-')}-${timestamp}.md`;
556
+
557
+ // Run task with each model
558
+ await Task({
559
+ subagent_type: "general-purpose",
560
+ description: `Run task with ${model}`,
561
+ prompt: `
562
+ Use Claudish to run this task with ${model}:
563
+
564
+ ${task}
565
+
566
+ STEPS:
567
+ 1. Run: claudish --model ${model} --json "${task}"
568
+ 2. Parse JSON output
569
+ 3. Return ONLY:
570
+ - Cost (from total_cost_usd)
571
+ - Duration (from duration_ms)
572
+ - Token usage (from usage.input_tokens and usage.output_tokens)
573
+ - Brief quality assessment (1-2 sentences)
574
+
575
+ DO NOT return full output.
576
+ `
577
+ });
578
+
579
+ results.push({
580
+ model,
581
+ resultFile
582
+ });
583
+ }
584
+
585
+ return results;
586
+ }
587
+ ```
588
+
589
+ ## Common Workflows
590
+
591
+ ### Workflow 1: Quick Code Generation with Grok
592
+
593
+ ```bash
594
+ # Fast, agentic coding with visible reasoning
595
+ claudish --model x-ai/grok-code-fast-1 "add error handling to api routes"
596
+ ```
597
+
598
+ ### Workflow 2: Complex Refactoring with GPT-5
599
+
600
+ ```bash
601
+ # Advanced reasoning for complex tasks
602
+ claudish --model openai/gpt-5 "refactor authentication system to use OAuth2"
603
+ ```
604
+
605
+ ### Workflow 3: UI Implementation with Qwen (Vision)
606
+
607
+ ```bash
608
+ # Vision-language model for UI tasks
609
+ claudish --model qwen/qwen3-vl-235b-a22b-instruct "implement dashboard from figma design"
610
+ ```
611
+
612
+ ### Workflow 4: Code Review with Gemini
613
+
614
+ ```bash
615
+ # State-of-the-art reasoning for thorough review
616
+ git diff | claudish --stdin --model google/gemini-2.5-flash "Review these changes for bugs and improvements"
617
+ ```
618
+
619
+ ### Workflow 5: Multi-Model Consensus
620
+
621
+ ```bash
622
+ # Run same task with multiple models
623
+ for model in "x-ai/grok-code-fast-1" "google/gemini-2.5-flash" "openai/gpt-5"; do
624
+ echo "=== Testing with $model ==="
625
+ claudish --model "$model" "find security vulnerabilities in auth.ts"
626
+ done
627
+ ```
628
+
629
+ ## Claudish CLI Flags Reference
630
+
631
+ ### Essential Flags
632
+
633
+ | Flag | Description | Example |
634
+ |------|-------------|---------|
635
+ | `--model <model>` | OpenRouter model to use | `--model x-ai/grok-code-fast-1` |
636
+ | `--stdin` | Read prompt from stdin | `git diff \| claudish --stdin --model grok` |
637
+ | `--list-models` | List available models | `claudish --list-models` |
638
+ | `--json` | JSON output (implies --quiet) | `claudish --json "task"` |
639
+ | `--help-ai` | Print AI agent usage guide | `claudish --help-ai` |
640
+
641
+ ### Advanced Flags
642
+
643
+ | Flag | Description | Default |
644
+ |------|-------------|---------|
645
+ | `--interactive` / `-i` | Interactive mode | Auto (no prompt = interactive) |
646
+ | `--quiet` / `-q` | Suppress log messages | Quiet in single-shot |
647
+ | `--verbose` / `-v` | Show log messages | Verbose in interactive |
648
+ | `--debug` / `-d` | Enable debug logging to file | Disabled |
649
+ | `--port <port>` | Proxy server port | Random (3000-9000) |
650
+ | `--no-auto-approve` | Require permission prompts | Auto-approve enabled |
651
+ | `--dangerous` | Disable sandbox | Disabled |
652
+ | `--monitor` | Proxy to real Anthropic API (debug) | Disabled |
653
+ | `--force-update` | Force refresh model cache | Auto (>2 days) |
654
+
655
+ ### Output Modes
656
+
657
+ 1. **Quiet Mode (default in single-shot)**
658
+ ```bash
659
+ claudish --model grok "task"
660
+ # Clean output, no [claudish] logs
661
+ ```
662
+
663
+ 2. **Verbose Mode**
664
+ ```bash
665
+ claudish --verbose "task"
666
+ # Shows all [claudish] logs for debugging
667
+ ```
668
+
669
+ 3. **JSON Mode**
670
+ ```bash
671
+ claudish --json "task"
672
+ # Structured output: {result, cost, usage, duration}
673
+ ```
674
+
675
+ ## Cost Tracking
676
+
677
+ Claudish automatically tracks costs in the status line:
678
+
679
+ ```
680
+ directory • model-id • $cost • ctx%
681
+ ```
682
+
683
+ **Example:**
684
+ ```
685
+ my-project • x-ai/grok-code-fast-1 • $0.12 • 67%
686
+ ```
687
+
688
+ Shows:
689
+ - 💰 **Cost**: $0.12 USD spent in current session
690
+ - 📊 **Context**: 67% of context window remaining
691
+
692
+ **JSON Output Cost:**
693
+ ```bash
694
+ claudish --json "task" | jq '.total_cost_usd'
695
+ # Output: 0.068
696
+ ```
697
+
698
+ ## Error Handling
699
+
700
+ ### Error 1: OPENROUTER_API_KEY Not Set
701
+
702
+ **Error:**
703
+ ```
704
+ Error: OPENROUTER_API_KEY environment variable is required
705
+ ```
706
+
707
+ **Fix:**
708
+ ```bash
709
+ export OPENROUTER_API_KEY='sk-or-v1-...'
710
+ # Or add to ~/.zshrc or ~/.bashrc
711
+ ```
712
+
713
+ ### Error 2: Claudish Not Installed
714
+
715
+ **Error:**
716
+ ```
717
+ command not found: claudish
718
+ ```
719
+
720
+ **Fix:**
721
+ ```bash
722
+ npm install -g claudish
723
+ # Or: bun install -g claudish
724
+ ```
725
+
726
+ ### Error 3: Model Not Found
727
+
728
+ **Error:**
729
+ ```
730
+ Model 'invalid/model' not found
731
+ ```
732
+
733
+ **Fix:**
734
+ ```bash
735
+ # List available models
736
+ claudish --list-models
737
+
738
+ # Use valid model ID
739
+ claudish --model x-ai/grok-code-fast-1 "task"
740
+ ```
741
+
742
+ ### Error 4: OpenRouter API Error
743
+
744
+ **Error:**
745
+ ```
746
+ OpenRouter API error: 401 Unauthorized
747
+ ```
748
+
749
+ **Fix:**
750
+ 1. Check API key is correct
751
+ 2. Verify API key at https://openrouter.ai/keys
752
+ 3. Check API key has credits (free tier or paid)
753
+
754
+ ### Error 5: Port Already in Use
755
+
756
+ **Error:**
757
+ ```
758
+ Error: Port 3000 already in use
759
+ ```
760
+
761
+ **Fix:**
762
+ ```bash
763
+ # Let Claudish pick random port (default)
764
+ claudish --model grok "task"
765
+
766
+ # Or specify different port
767
+ claudish --port 8080 --model grok "task"
768
+ ```
769
+
770
+ ## Best Practices
771
+
772
+ ### 1. ✅ Use File-Based Instructions
773
+
774
+ **Why:** Avoids context window pollution
775
+
776
+ **How:**
777
+ ```bash
778
+ # Write instruction to file
779
+ echo "Implement feature X" > /tmp/task.md
780
+
781
+ # Run with stdin
782
+ claudish --stdin --model grok < /tmp/task.md > /tmp/result.md
783
+
784
+ # Read result
785
+ cat /tmp/result.md
786
+ ```
787
+
788
+ ### 2. ✅ Choose Right Model for Task
789
+
790
+ **Fast Coding:** `x-ai/grok-code-fast-1`
791
+ **Complex Reasoning:** `google/gemini-2.5-flash` or `openai/gpt-5`
792
+ **Vision/UI:** `qwen/qwen3-vl-235b-a22b-instruct`
793
+
794
+ ### 3. ✅ Use --json for Automation
795
+
796
+ **Why:** Structured output, easier parsing
797
+
798
+ **How:**
799
+ ```bash
800
+ RESULT=$(claudish --json "task" | jq -r '.result')
801
+ COST=$(claudish --json "task" | jq -r '.total_cost_usd')
802
+ ```
803
+
804
+ ### 4. ✅ Delegate to Sub-Agents
805
+
806
+ **Why:** Keeps main conversation context clean
807
+
808
+ **How:**
809
+ ```typescript
810
+ await Task({
811
+ subagent_type: "general-purpose",
812
+ description: "Task with Claudish",
813
+ prompt: "Use claudish --model grok '...' and return summary only"
814
+ });
815
+ ```
816
+
817
+ ### 5. ✅ Update Models Regularly
818
+
819
+ **Why:** Get latest model recommendations
820
+
821
+ **How:**
822
+ ```bash
823
+ # Auto-updates every 2 days
824
+ claudish --list-models
825
+
826
+ # Force update now
827
+ claudish --list-models --force-update
828
+ ```
829
+
830
+ ### 6. ✅ Use --stdin for Large Prompts
831
+
832
+ **Why:** Avoid command line length limits
833
+
834
+ **How:**
835
+ ```bash
836
+ git diff | claudish --stdin --model grok "Review changes"
837
+ ```
838
+
839
+ ## Anti-Patterns (Avoid These)
840
+
841
+ ### ❌❌❌ NEVER Run Claudish Directly in Main Conversation (CRITICAL)
842
+
843
+ **This is the #1 mistake. Never do this unless user explicitly requests it.**
844
+
845
+ **WRONG - Destroys context window:**
846
+ ```typescript
847
+ // ❌ NEVER DO THIS - Pollutes main context with 10K+ tokens
848
+ await Bash("claudish --model grok 'implement feature'");
849
+
850
+ // ❌ NEVER DO THIS - Full conversation in main context
851
+ await Bash("claudish --model gemini 'review code'");
852
+
853
+ // ❌ NEVER DO THIS - Even with --json, output is huge
854
+ const result = await Bash("claudish --json --model gpt-5 'refactor'");
855
+ ```
856
+
857
+ **RIGHT - Always use sub-agents:**
858
+ ```typescript
859
+ // ✅ ALWAYS DO THIS - Delegate to sub-agent
860
+ const result = await Task({
861
+ subagent_type: "general-purpose", // or specific agent
862
+ description: "Implement feature with Grok",
863
+ prompt: `
864
+ Use Claudish to implement the feature with Grok model.
865
+
866
+ CRITICAL INSTRUCTIONS:
867
+ 1. Create instruction file: /tmp/claudish-task-${Date.now()}.md
868
+ 2. Write detailed task requirements to file
869
+ 3. Run: claudish --model x-ai/grok-code-fast-1 --stdin < /tmp/claudish-task-*.md
870
+ 4. Read result file and return ONLY a 2-3 sentence summary
871
+
872
+ DO NOT return full implementation or conversation.
873
+ Keep response under 300 tokens.
874
+ `
875
+ });
876
+
877
+ // ✅ Even better - Use specialized agent if available
878
+ const result = await Task({
879
+ subagent_type: "backend-developer", // or frontend-dev, etc.
880
+ description: "Implement with external model",
881
+ prompt: `
882
+ Use Claudish with x-ai/grok-code-fast-1 model to implement authentication.
883
+ Follow file-based instruction pattern.
884
+ Return summary only.
885
+ `
886
+ });
887
+ ```
888
+
889
+ **When you CAN run directly (rare exceptions):**
890
+ ```typescript
891
+ // ✅ Only when user explicitly requests
892
+ // User: "Run claudish directly in main context for debugging"
893
+ if (userExplicitlyRequestedDirect) {
894
+ await Bash("claudish --model grok 'task'");
895
+ }
896
+ ```
897
+
898
+ ### ❌ Don't Ignore Model Selection
899
+
900
+ **Wrong:**
901
+ ```bash
902
+ # Always using default model
903
+ claudish "any task"
904
+ ```
905
+
906
+ **Right:**
907
+ ```bash
908
+ # Choose appropriate model
909
+ claudish --model x-ai/grok-code-fast-1 "quick fix"
910
+ claudish --model google/gemini-2.5-flash "complex analysis"
911
+ ```
912
+
913
+ ### ❌ Don't Parse Text Output
914
+
915
+ **Wrong:**
916
+ ```bash
917
+ OUTPUT=$(claudish --model grok "task")
918
+ COST=$(echo "$OUTPUT" | grep cost | awk '{print $2}')
919
+ ```
920
+
921
+ **Right:**
922
+ ```bash
923
+ # Use JSON output
924
+ COST=$(claudish --json --model grok "task" | jq -r '.total_cost_usd')
925
+ ```
926
+
927
+ ### ❌ Don't Hardcode Model Lists
928
+
929
+ **Wrong:**
930
+ ```typescript
931
+ const MODELS = ["x-ai/grok-code-fast-1", "openai/gpt-5"];
932
+ ```
933
+
934
+ **Right:**
935
+ ```typescript
936
+ // Query dynamically
937
+ const { stdout } = await Bash("claudish --list-models --json");
938
+ const models = JSON.parse(stdout).models.map(m => m.id);
939
+ ```
940
+
941
+ ### ❌ Don't Skip Error Handling
942
+
943
+ **Wrong:**
944
+ ```typescript
945
+ const result = await Bash("claudish --model grok 'task'");
946
+ ```
947
+
948
+ **Right:**
949
+ ```typescript
950
+ try {
951
+ const result = await Bash("claudish --model grok 'task'");
952
+ } catch (error) {
953
+ console.error("Claudish failed:", error.message);
954
+ // Fallback to embedded Claude or handle error
955
+ }
956
+ ```
957
+
958
+ ## Agent Integration Examples
959
+
960
+ ### Example 1: Code Review Agent
961
+
962
+ ```typescript
963
+ /**
964
+ * Agent: code-reviewer (using Claudish with multiple models)
965
+ */
966
+ async function reviewCodeWithMultipleModels(files: string[]) {
967
+ const models = [
968
+ "x-ai/grok-code-fast-1", // Fast initial scan
969
+ "google/gemini-2.5-flash", // Deep analysis
970
+ "openai/gpt-5" // Final validation
971
+ ];
972
+
973
+ const reviews = [];
974
+
975
+ for (const model of models) {
976
+ const timestamp = Date.now();
977
+ const instructionFile = `/tmp/review-${model.replace('/', '-')}-${timestamp}.md`;
978
+ const resultFile = `/tmp/review-result-${model.replace('/', '-')}-${timestamp}.md`;
979
+
980
+ // Create instruction
981
+ const instruction = createReviewInstruction(files, resultFile);
982
+ await Write({ file_path: instructionFile, content: instruction });
983
+
984
+ // Run review with model
985
+ await Bash(`claudish --model ${model} --stdin < ${instructionFile}`);
986
+
987
+ // Read result
988
+ const result = await Read({ file_path: resultFile });
989
+
990
+ // Extract summary
991
+ reviews.push({
992
+ model,
993
+ summary: extractSummary(result),
994
+ issueCount: extractIssueCount(result)
995
+ });
996
+
997
+ // Clean up
998
+ await Bash(`rm ${instructionFile} ${resultFile}`);
999
+ }
1000
+
1001
+ return reviews;
1002
+ }
1003
+ ```
1004
+
1005
+ ### Example 2: Feature Implementation Command
1006
+
1007
+ ```typescript
1008
+ /**
1009
+ * Command: /implement-with-model
1010
+ * Usage: /implement-with-model "feature description"
1011
+ */
1012
+ async function implementWithModel(featureDescription: string) {
1013
+ // Step 1: Get available models
1014
+ const { stdout } = await Bash("claudish --list-models --json");
1015
+ const models = JSON.parse(stdout).models;
1016
+
1017
+ // Step 2: Let user select model
1018
+ const selectedModel = await promptUserForModel(models);
1019
+
1020
+ // Step 3: Create instruction file
1021
+ const timestamp = Date.now();
1022
+ const instructionFile = `/tmp/implement-${timestamp}.md`;
1023
+ const resultFile = `/tmp/implement-result-${timestamp}.md`;
1024
+
1025
+ const instruction = `# Feature Implementation
1026
+
1027
+ ## Description
1028
+ ${featureDescription}
1029
+
1030
+ ## Requirements
1031
+ - Write clean, maintainable code
1032
+ - Add comprehensive tests
1033
+ - Include error handling
1034
+ - Follow project conventions
1035
+
1036
+ ## Output
1037
+ Write implementation details to: ${resultFile}
1038
+
1039
+ Include:
1040
+ - Files created/modified
1041
+ - Code snippets
1042
+ - Test coverage
1043
+ - Documentation updates
1044
+ `;
1045
+
1046
+ await Write({ file_path: instructionFile, content: instruction });
1047
+
1048
+ // Step 4: Run implementation
1049
+ await Bash(`claudish --model ${selectedModel} --stdin < ${instructionFile}`);
1050
+
1051
+ // Step 5: Read and present results
1052
+ const result = await Read({ file_path: resultFile });
1053
+
1054
+ // Step 6: Clean up
1055
+ await Bash(`rm ${instructionFile} ${resultFile}`);
1056
+
1057
+ return result;
1058
+ }
1059
+ ```
1060
+
1061
+ ## Troubleshooting
1062
+
1063
+ ### Issue: Slow Performance
1064
+
1065
+ **Symptoms:** Claudish takes long time to respond
1066
+
1067
+ **Solutions:**
1068
+ 1. Use faster model: `x-ai/grok-code-fast-1` or `minimax/minimax-m2`
1069
+ 2. Reduce prompt size (use --stdin with concise instructions)
1070
+ 3. Check internet connection to OpenRouter
1071
+
1072
+ ### Issue: High Costs
1073
+
1074
+ **Symptoms:** Unexpected API costs
1075
+
1076
+ **Solutions:**
1077
+ 1. Use budget-friendly models (check pricing with `--list-models`)
1078
+ 2. Enable cost tracking: `--cost-tracker`
1079
+ 3. Use --json to monitor costs: `claudish --json "task" | jq '.total_cost_usd'`
1080
+
1081
+ ### Issue: Context Window Exceeded
1082
+
1083
+ **Symptoms:** Error about token limits
1084
+
1085
+ **Solutions:**
1086
+ 1. Use model with larger context (Gemini: 1000K, Grok: 256K)
1087
+ 2. Break task into smaller subtasks
1088
+ 3. Use file-based pattern to avoid conversation history
1089
+
1090
+ ### Issue: Model Not Available
1091
+
1092
+ **Symptoms:** "Model not found" error
1093
+
1094
+ **Solutions:**
1095
+ 1. Update model cache: `claudish --list-models --force-update`
1096
+ 2. Check OpenRouter website for model availability
1097
+ 3. Use alternative model from same category
1098
+
1099
+ ## Additional Resources
1100
+
1101
+ **Documentation:**
1102
+ - Full README: `/Users/jack/mag/claude-code/mcp/claudish/README.md`
1103
+ - AI Agent Guide: Print with `claudish --help-ai`
1104
+ - Model Integration: `/Users/jack/mag/claude-code/skills/claudish-integration/SKILL.md`
1105
+
1106
+ **External Links:**
1107
+ - Claudish GitHub: https://github.com/MadAppGang/claude-code
1108
+ - OpenRouter: https://openrouter.ai
1109
+ - OpenRouter Models: https://openrouter.ai/models
1110
+ - OpenRouter API Docs: https://openrouter.ai/docs
1111
+
1112
+ **Version Information:**
1113
+ ```bash
1114
+ claudish --version
1115
+ ```
1116
+
1117
+ **Get Help:**
1118
+ ```bash
1119
+ claudish --help # CLI usage
1120
+ claudish --help-ai # AI agent usage guide
1121
+ ```
1122
+
1123
+ ---
1124
+
1125
+ **Maintained by:** MadAppGang
1126
+ **Last Updated:** November 19, 2025
1127
+ **Skill Version:** 1.0.0