netra-zen 1.0.10__py3-none-any.whl → 1.1.2__py3-none-any.whl

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.
@@ -1,971 +1,992 @@
1
- Metadata-Version: 2.4
2
- Name: netra-zen
3
- Version: 1.0.10
4
- Summary: Multi-instance Claude orchestrator for parallel task execution
5
- Home-page: https://github.com/netra-systems/zen
6
- Author: Systems
7
- Author-email: Netra Systems <pypi@netrasystems.ai>
8
- License: MIT
9
- Project-URL: Homepage, https://github.com/netra-systems/zen
10
- Project-URL: Documentation, https://github.com/netra-systems/zen#readme
11
- Project-URL: Repository, https://github.com/netra-systems/zen.git
12
- Project-URL: Bug Tracker, https://github.com/netra-systems/zen/issues
13
- Project-URL: Changelog, https://github.com/netra-systems/zen/blob/main/CHANGELOG.md
14
- Keywords: claude,ai,orchestration,parallel,automation,llm,anthropic
15
- Classifier: Development Status :: 4 - Beta
16
- Classifier: Intended Audience :: Developers
17
- Classifier: License :: Other/Proprietary License
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Programming Language :: Python :: 3
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
- Classifier: Programming Language :: Python :: 3.10
23
- Classifier: Programming Language :: Python :: 3.11
24
- Classifier: Programming Language :: Python :: 3.12
25
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
- Classifier: Topic :: Software Development :: Quality Assurance
27
- Classifier: Topic :: System :: Distributed Computing
28
- Requires-Python: >=3.8
29
- Description-Content-Type: text/markdown
30
- License-File: LICENSE.md
31
- Requires-Dist: PyYAML>=6.0
32
- Requires-Dist: python-dateutil>=2.8.2
33
- Requires-Dist: aiohttp>=3.8.0
34
- Requires-Dist: websockets>=11.0
35
- Requires-Dist: rich>=13.0.0
36
- Requires-Dist: PyJWT>=2.8.0
37
- Requires-Dist: psutil>=5.9.0
38
- Requires-Dist: opentelemetry-sdk>=1.20.0
39
- Requires-Dist: opentelemetry-exporter-gcp-trace>=1.6.0
40
- Requires-Dist: google-cloud-trace>=1.11.0
41
- Provides-Extra: dev
42
- Requires-Dist: pytest>=7.0.0; extra == "dev"
43
- Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
44
- Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
45
- Requires-Dist: black>=23.0.0; extra == "dev"
46
- Requires-Dist: ruff>=0.1.0; extra == "dev"
47
- Requires-Dist: mypy>=1.0.0; extra == "dev"
48
- Provides-Extra: netra
49
- Requires-Dist: netraoptimizer>=1.0.0; extra == "netra"
50
- Dynamic: author
51
- Dynamic: home-page
52
- Dynamic: license-file
53
- Dynamic: requires-python
54
-
55
- # Free more claude usage through optimization.
56
-
57
- Extend your claude usage (all plans) for free with minimal effort and no risk.
58
-
59
- It works by analyzing your usage logs for metadata optimizations. It is focused on the metadata not the semantics of the prompt, so no risk in drop of quality.
60
-
61
- This is a micro startup effort, aiming to provide real value for individual devs in exchange for feedback. Our intent is to charge businesses for larger scale optimizations.
62
-
63
- The process is simple. One time install, then one command. It auto grabs the last 3 log files and provides actionable items to update going forward to get the value of the optimizations.
64
-
65
- ## Quick start
66
-
67
- 1. `pip install netra-zen`
68
- 2. `zen --apex --send-logs`
69
- 3. Read the results and update claude settings, prompts, commands, etc. as needed to benefit
70
-
71
- See detailed install below if needed.
72
-
73
- ### Log Collection Options
74
-
75
- The optimizer analyzes your Claude Code usage logs to identify optimization opportunities. You can customize what logs are sent:
76
-
77
- ```bash
78
- # Send logs from the 3 most recent files (default)
79
- zen --apex --send-logs
80
-
81
- # Send logs from more files for deeper analysis
82
- zen --apex --send-logs --logs-count 5
83
-
84
- # Send logs from a specific project
85
- zen --apex --send-logs --logs-project "my-project-name"
86
-
87
- # Send logs from a custom location
88
- zen --apex --send-logs --logs-path "/path/to/.claude/Projects"
89
-
90
- # Combine options for targeted analysis
91
- zen --apex --send-logs --logs-count 3 --logs-project "production-app"
92
- ```
93
-
94
- **Important:**
95
- - `--logs-count` specifies the number of **files** to read, not entries
96
- - Each file may contain many log entries
97
- - The tool will display exactly how many entries from how many files are being sent
98
-
99
- ## Example output
100
- ![example](https://github.com/user-attachments/assets/94ed0180-9fed-4d76-ab69-657b7d3ab1b2)
101
-
102
-
103
- ## Proof it works
104
- ### Example savings on real world production git issue progressor task (complex claude code command)
105
- This was just changing a few small lines on a 400 line command.
106
- ![savings](https://github.com/user-attachments/assets/9298e7cc-4f15-4dc0-97e3-1f126757dde6)
107
-
108
- ## Notes
109
- - Have an optimization idea or area you want it to focus on? Create a git issue and we can add that to our evals.
110
-
111
- ## Example output from single file
112
- ```
113
- zen --apex --send-logs --logs-path /Users/user/.claude/projects/-Users-Desktop-netra-apex/7ac6d7ac-abc3-4903-a482-......-1.jsonl
114
-
115
- SUCCESS: WebSocket connected successfully!
116
-
117
- ============================================================
118
- 📤 SENDING LOGS TO OPTIMIZER
119
- ============================================================
120
- Total Entries: 781
121
- Files Read: 1
122
- Payload Size: 5.52 MB
123
-
124
- Files:
125
- • 7ac6d7ac-abc3-4903-a482-.....jsonl (hash: 908dbc51, 781 entries)
126
-
127
- Payload Confirmation:
128
- 'jsonl_logs' key added to payload
129
- First log entry timestamp: 2025-10-03T18:26:02.089Z
130
- ✓ Last log entry timestamp: 2025-10-03T19:31:21.876Z
131
- ============================================================
132
-
133
- [11:32:55.190] [DEBUG] GOLDEN PATH TRACE: Prepared WebSocket payload for run_id=cli_20251008_113255_25048,
134
- thread_id=cli_thread_f887c58e7759
135
- [11:32:55.191] [DEBUG] TRANSMISSION PROOF: Payload contains 781 JSONL log entries in 'jsonl_logs' key
136
- SUCCESS: Message sent with run_id: cli_20251008_113255_25048
137
- Waiting 120 seconds for events...
138
- Receiving events...
139
- [11:32:55.284] [DEBUG] Listening for WebSocket events...
140
- [11:32:55.284] [DEBUG] GOLDEN PATH TRACE: Event listener started after successful connection
141
- [11:32:56.655] [DEBUG] WebSocket Event #1: raw_message_received
142
- [11:32:56.657] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=connection_established
143
- [11:32:56.658] [DEBUG] WebSocket Event #2: connection_established
144
- [11:32:56] [CONN] Connected as: e2e-staging-2d677771
145
- [11:33:01.364] [DEBUG] WebSocket Event #3: raw_message_received
146
- [11:33:01.366] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=thread_created
147
- [11:33:01.367] [DEBUG] WebSocket Event #4: thread_created
148
- [11:33:01] [EVENT] thread_created: {"type": "thread_created", "payload": {"thread_id":
149
- "thread_session_969_44184cce", "timestamp": 1759...
150
- [11:33:02.901] [DEBUG] WebSocket Event #5: raw_message_received
151
- [11:33:02.903] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
152
- [11:33:02.904] [DEBUG] WebSocket Event #6: agent_started
153
- [11:33:02] 🧠 Agent: netra-assistant started (run: run_sess...)
154
- [11:33:04.744] [DEBUG] WebSocket Event #7: raw_message_received
155
- [11:33:04.746] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
156
- [11:33:04.747] [DEBUG] WebSocket Event #8: agent_started
157
- [11:33:04] 🧠 Agent: netra-assistant started (run: run_sess...)
158
- [11:33:06.366] [DEBUG] WebSocket Event #9: raw_message_received
159
- [11:33:06.368] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
160
- [11:33:06.369] [DEBUG] WebSocket Event #10: agent_started
161
- [11:33:06] 🧠 Agent: MessageHandler started (run: run_sess...)
162
- [11:33:14.781] [DEBUG] WebSocket Event #11: raw_message_received
163
- [11:33:14.783] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
164
- [11:33:14.784] [DEBUG] WebSocket Event #12: agent_started
165
- [11:33:14] 🧠 Agent: claude_code_optimizer started (run: run_sess...)
166
- [11:33:23.241] [DEBUG] WebSocket Event #13: raw_message_received
167
- [11:33:23.243] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_thinking
168
- [11:33:23.244] [DEBUG] WebSocket Event #14: agent_thinking
169
- [11:33:23] 💭 Thinking: Preparing optimization prompt
170
- ⠹ 💭 Preparing optimization prompt[11:34:27.586] [DEBUG] WebSocket Event #15: raw_message_received
171
- [11:34:27.588] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_completed
172
- [11:34:27.589] [DEBUG] WebSocket Event #16: agent_completed
173
- 💭 Preparing optimization prompt
174
- [11:34:27] 🧠 Agent Completed: claude_code_optimizer (run: run_sess...) - {"status": "done", "result":
175
- {"optimizations": [{"issue": "Repeated Full File Read", "evidence": "Th...
176
- ╭────────────────────────────────── Final Agent Result - Optimization Pointers ──────────────────────────────────╮
177
- {
178
- │ "status": "done",
179
- "result": {
180
- "optimizations": [
181
- {
182
- │ "issue": "Repeated Full File Read",
183
- "evidence": "The file `api/src/routes/user.js` was read in its entirety using `cat` twice. The model
184
- read it once to understand the code, but then read the entire file again later to re-confirm a detail it had
185
- forgotten.",
186
- "token_waste": "High (~2.5k tokens). The entire content of the 250-line file was added to the context
187
- a second time, providing no new information.",
188
- "fix": "The model should retain the context of files it has already read within the same task. If it
189
- needs to re-check a specific detail, it should use a targeted tool like `grep` or `read_lines` (e.g., `grep -C
190
- 5 'findUser' api/src/routes/user.js`) instead of re-reading the entire file.",
191
- "ideal prompt": "The user profile page isn't loading the user's name. The API endpoint is in
192
- `api/src/routes/user.js` and it calls the `findUser` function from `api/src/db/utils.js`. Please investigate
193
- the data flow between these two files and fix the issue.",
194
- "priority": "high"
195
- },
196
- {
197
- │ "issue": "Excessive Context Gathering",
198
- "evidence": "The `cat` command was used on two large files (`user.js` and `utils.js`), ingesting a │
199
- total of 400 lines of code into the context. The actual bug was confined to a small 5-line function within
200
- `utils.js`.",
201
- "token_waste": "High (~4k tokens). Most of the file content was irrelevant to the specific task of
202
- fixing the `findUser` function's return value.",
203
- "fix": "Instead of `cat`, the model should use more precise tools to gather context. After identifying
204
- the relevant function with `grep`, it could have used a command like `read_lines('api/src/db/utils.js',
205
- start_line, end_line)` or `grep -A 10 'const findUser' api/src/db/utils.js` to read only the function's
206
- definition and its immediate surroundings.",
207
- "ideal prompt": "The `findUser` function in `api/src/db/utils.js` is not returning the user's name
208
- field. Please add it to the return object.",
209
- "priority": "high"
210
- },
211
- {
212
- │ "issue": "Inefficient Project-Wide Search",
213
- "evidence": "A recursive grep (`grep -r \"findUser\" .`) was used to find the definition of
214
- `findUser`. While effective, this can be slow and return a lot of irrelevant matches (like comments, logs,
215
- etc.) in a large codebase, consuming tokens in the tool output.",
216
- "token_waste": "Medium (~500 tokens). The `grep` returned multiple matches, including the call site
217
- which was already known. In a larger project, this could return dozens of matches.",
218
- "fix": "If the project structure is conventional, a more targeted search would be better. For example,
219
- knowing `db` utilities are likely in a `db` or `utils` directory, a command like `grep 'findUser'
220
- │ api/src/db/*.js` would be more direct and produce less noise.",
221
- "ideal prompt": "The `findUser` function, defined in the `api/src/db/` directory, seems to be causing
222
- a bug. Can you find its definition and check what it returns?",
223
- "priority": "low"
224
- }
225
- ],
226
- "summary": {
227
- │ "total_issues": 3,
228
- │ "estimated_savings": "~7k tokens",
229
- "top_priority": "Avoid repeated full file reads. The model should trust its context or use targeted
230
- tools like `grep` to refresh specific details instead of re-ingesting entire files."
231
- }
232
- },
233
- "message": "Claude Code optimization analysis complete"
234
- │ } │
235
- ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
236
-
237
- 📊 Received 8 events
238
- ```
239
-
240
- # Advanced features & detailed install guide
241
-
242
- In addition to optimizing your costs and latency,
243
- you can control budgets and other advanced features.
244
-
245
- ### Orchestrator
246
-
247
- Orchestrator allows you to:
248
- - Orchestrator runs multiple Code CLI instances for peaceful parallel task execution.
249
- - Run multiple headless Claude Code CLI instances simultaneously.
250
- - Calm unified results (status, time, token usage)
251
- - Relax **"5-hour limit reached"** lockout fears with easy token budget limits
252
- - Get more value out of your Claude MAX subscription
253
- with scheduling features. (`--run-at "2am"`)
254
- - Learn more about how Claude Code uses tools and other inner workings
255
- - Control usage and budget for groups of work or per command
256
-
257
- Example portion of status report:
258
- ```
259
- ╔═══ STATUS REPORT [14:25:10] ═══╗
260
- ║ Total: 5 instances
261
- Running: 3, Completed: 2, Failed: 0
262
- ║ Tokens: 32.1K total | Tools: 15
263
- 💰 Cost: $0.0642 total
264
-
265
- ║ TOKEN BUDGET STATUS
266
- Overall: [████████████----] 75% 32.1K/43.0K
267
-
268
- ║ Status Name Duration Tokens
269
- ║ ──────── ───────────────── ─────── ──────
270
- ║ ✅ security-reviewer 2m15s 8.5K
271
- ║ ✅ performance-analyzer 1m42s 7.2K
272
- ║ 🏃 architecture-reviewer 1m18s 6.5K
273
- ║ 🏃 test-coverage-analyst 0m45s 4.8K
274
- ║ ⏳ quality-synthesizer queued 0K
275
- ╚════════════════════════════════════════════╝
276
- ```
277
-
278
- ## Example Start
279
- ```
280
- zen
281
- ```
282
-
283
- ```
284
- +=== STATUS REPORT [14:47:39] ===+
285
- | Total: 2 instances
286
- | Running: 2, Completed: 0, Failed: 0, Pending: 0
287
- | Tokens: 0 total, 0 cached | Median: 0 | Tools: 0
288
- | 💰 Cost: $0.0000 total, $0.0000 avg/instance | Pricing: Claude compliant
289
- |
290
- | TOKEN BUDGET STATUS |
291
- | Overall: [--------------------] 0% 0/10.0K
292
- | Command Budgets:
293
- | /analyze-repository [--------------------] 0% 0/5.0K
294
- | /README [--------------------] 0% 0/1.0K
295
- |
296
- | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
297
- | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
298
- | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
299
- | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
300
- | 🏃 analyze-repo opus4 5.1s 0 0 0 0 0 0/5.0K
301
- | 🏃 help-overview sonnet4 0.0s 0 0 0 0 0 0/1.0K
302
- +================================+
303
- ```
304
-
305
- ## Budget Warning Only
306
- ```
307
- zen --overall-token-budget 10000
308
- ```
309
- ```
310
- +=== STATUS REPORT [14:47:44] ===+
311
- | Total: 2 instances
312
- | Running: 2, Completed: 0, Failed: 0, Pending: 0
313
- | Tokens: 32.2K total, 32.2K cached | Median: 32.2K | Tools: 1
314
- | 💰 Cost: $0.0818 total, $0.0409 avg/instance | Pricing: Claude compliant
315
- |
316
- | TOKEN BUDGET STATUS |
317
- | Overall: [####################] 100% 32.2K/10.0K
318
- | Command Budgets:
319
- | /analyze-repository [####################] 100% 32.2K/5.0K
320
- | /README [--------------------] 0% 0/1.0K
321
- |
322
- | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
323
- | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
324
- | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
325
- | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
326
- | 🏃 analyze-repo 35sonnet 10.1s 32.2K 5 20.9K 11.4K 1 32.2K/5.0K
327
- | 🏃 help-overview opus4 5.0s 0 0 0 0 0 0/1.0K
328
- +================================+
329
-
330
- +=== TOOL USAGE DETAILS ===+
331
- | Tool Name Uses Tokens Cost ($) Used By
332
- | -------------------- -------- ---------- ---------- -----------------------------------
333
- | Bash 1 33 0.0001 analyze-repo(1 uses, 33 tok)
334
- | -------------------- -------- ---------- ---------- -----------------------------------
335
- | TOTAL 1 33 0.0001
336
- +===============================================================================================+
337
- ```
338
-
339
- ## Budget Block
340
- ```
341
- zen --overall-token-budget 10000 --budget-enforcement-mode block
342
- ```
343
- ```
344
- 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - 💰 BUDGET UPDATE [analyze-repo]: Recording 32240 tokens for command '/analyze-repository'
345
- 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - 📊 BUDGET STATE [analyze-repo]: /analyze-repository now at 32240/5000 tokens (644.8%)
346
- 2025-09-18 14:50:42,050 - zen_orchestrator - ERROR - 🚫 🔴 RUNTIME TERMINATION: Runtime budget violation for analyze-repo: Overall budget exceeded: 32240/10000 tokens
347
- 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - Terminating instance analyze-repo (PID: 88916): Terminated due to budget violation - Overall budget exceeded: 32240/10000 tokens
348
- 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - Sent SIGTERM to analyze-repo (PID: 88916)
349
- ```
350
-
351
- ```
352
- +=== FINAL STATUS [14:50:57] ===+
353
- | Total: 2 instances
354
- | Running: 0, Completed: 0, Failed: 2, Pending: 0
355
- | Tokens: 85.6K total, 85.2K cached | Median: 42.8K | Tools: 1
356
- | 💰 Cost: $0.0889 total, $0.0444 avg/instance | Pricing: Claude compliant
357
- |
358
- | TOKEN BUDGET STATUS |
359
- | Overall: [####################] 100% 85.6K/10.0K
360
- | Command Budgets:
361
- | /analyze-repository [####################] 100% 48.4K/5.0K
362
- | /README [####################] 100% 37.2K/1.0K
363
- |
364
- | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
365
- | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
366
- | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
367
- | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
368
- | ❌ analyze-repo sonnet4 22.5s 48.4K 31 16.1K 32.2K 1 48.4K/5.0K
369
- | ❌ help-overview 35sonnet 16.2s 37.2K 422 0 36.8K 0 37.2K/1.0K
370
- +===============================+
371
-
372
- +=== TOOL USAGE DETAILS ===+
373
- | Tool Name Uses Tokens Cost ($) Used By
374
- | -------------------- -------- ---------- ---------- -----------------------------------
375
- | Task 1 348 0.0010 analyze-repo(1 uses, 348 tok)
376
- | -------------------- -------- ---------- ---------- -----------------------------------
377
- | TOTAL 1 348 0.0010
378
- +===============================================================================================+
379
- ```
380
-
381
- # Example Start At
382
- ```
383
- zen --start-at "2am"
384
- ```
385
-
386
- ```
387
- ...
388
- 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Added instance: analyze-repo - Analyze the repository structure and codebase
389
- 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Added instance: help-overview - Show project README and overview information
390
-
391
- 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Orchestration scheduled to start at: 2025-09-19 02:00:00
392
- 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Waiting 39930.1 seconds (11.1 hours) until start time...
393
- ```
394
-
395
- # Example Command
396
- **Assumes you have a claude command /runtests**
397
- ```
398
- zen "/runtests"
399
- ```
400
- ```
401
- ...
402
- 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Added instance: direct-runtests-3337c2c5 - Direct execution of /runtests
403
- 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Starting Claude Code instance orchestration
404
- 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Starting 1 instances with 5.0s delay between launches (timeout: 10000s each)
405
- 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Now starting instance 'direct-runtests-3337c2c5' (after 0.0s delay)
406
-
407
- ```
408
- # Example Config (Recommended Usage)
409
-
410
- Your JSON file as `path\my_config.json`
411
- ```JSON
412
- {
413
- "instances": [
414
- {
415
- "name": "analyze-repository",
416
- "command": "/analyze-repository; Spawn three subagents to understand how the information at this website is used in the zen directory. https://docs.claude.com/en/docs/about-claude/pricing#tool-use-pricing.",
417
- "description": "Reads and understands the required portion of the repository",
418
- "permission_mode": "bypassPermissions",
419
- "output_format": "stream-json",
420
- "max_tokens_per_command": 5000
421
- }
422
- ]
423
- }
424
- ```
425
- ```
426
- zen --config path\my_config.json
427
- ```
428
-
429
- ```
430
- ...
431
-
432
- 2025-09-18 15:00:09,645 - zen_orchestrator - INFO - Loading config from config_example.json
433
-
434
- 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - 🎯 Token transparency pricing engine enabled - Claude pricing compliance active
435
-
436
- 2025-09-18 15:00:09,657 - zen_orchestrator - WARNING - Command '/analyze-repository; Spawn three subagents to understand how the information at this website is used in the zen directory. https://docs.claude.com/en/docs/about-claude/pricing#tool-use-pricing.' not found in available commands
437
-
438
- 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - Available commands: /clear, /compact, /help
439
-
440
- 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - Added instance: analyze-repository - Reads and understands the required portion of the repository
441
-
442
- 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - Starting Claude Code instance orchestration
443
-
444
- 2025-09-18 15:00:09,659 - zen_orchestrator - INFO - Starting 1 instances with 5.0s delay between launches (timeout: 10000s each)
445
-
446
- 2025-09-18 15:00:09,659 - zen_orchestrator - INFO - Now starting instance 'analyze-repository' (after 0.0s delay)
447
-
448
- 2025-09-18 15:00:09,659 - zen_orchestrator - INFO - Starting instance: analyze-repository
449
-
450
- 2025-09-18 15:00:09,665 - zen_orchestrator - INFO - Command: claude.CMD -p /analyze-repository; Spawn three subagents to understand how the information at this website is used in the zen directory. https://docs.claude.com/en/docs/about-claude/pricing#tool-use-pricing. --output-format=stream-json --permission-mode=bypassPermissions --verbose
451
-
452
- 2025-09-18 15:00:09,738 - zen_orchestrator - INFO - Permission mode: bypassPermissions (Platform: Windows)
453
- 2025-09-18 15:00:09,746 - zen_orchestrator - INFO - Instance analyze-repository started with PID 672
454
-
455
- +=== STATUS REPORT [15:00:14] ===+
456
- | Total: 1 instances
457
- | Running: 1, Completed: 0, Failed: 0, Pending: 0
458
- | Tokens: 0 total, 0 cached | Median: 0 | Tools: 0
459
- | 💰 Cost: $0.0000 total, $0.0000 avg/instance | Pricing: Claude compliant
460
- |
461
- | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
462
- | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
463
- | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
464
- | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
465
- | 🏃 analyze-repository opus4 5.1s 0 0 0 0 0 -
466
- +================================+
467
-
468
-
469
- +=== STATUS REPORT [15:00:19] ===+
470
- | Total: 1 instances
471
- | Running: 1, Completed: 0, Failed: 0, Pending: 0
472
- | Tokens: 14.7K total, 14.7K cached | Median: 14.7K | Tools: 0
473
- | 💰 Cost: $0.0798 total, $0.0798 avg/instance | Pricing: Claude compliant
474
- | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
475
- | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
476
- | 🏃 analyze-repository opus4 10.1s 14.7K 6 3.3K 11.4K 0 -
477
- +================================+
478
-
479
- ```
480
-
481
-
482
- ## Inspiration and background
483
- While developing Netra Apex (commercial product)
484
- our team has been running 100s of parallel claude code instances.
485
- During that process we got annoyed at the "cognitive overhead"
486
- of each having 10s of terminals open per machine and scrolling mountains of text.
487
- Did the `/command` work or not?
488
-
489
- What started as a simple way to make that process more peaceful turned into something we believe will be useful to the community.
490
-
491
- Further, as usage limits become more restrictive, getting up at odd hours just to feed the beast got old fast. So we added scheduling to run it at pre-defined times.
492
-
493
- Surprisingly, the duration that a command ran and it's presumed difficulty, often had little correlation with actual token usage.
494
- "Simple" git operations would sometimes eat 10x as many as complex issue resolution commands.
495
-
496
- The market is moving quickly, codex is getting better and other Code CLIs are coming. How effective a code factory is matters. This V1 alpha is just the start of codifying code CLI dev practices and progressing from alchemy to engineering.
497
-
498
- For more power, try Zen with Netra Apex for the most effective usage and control of business AI spend.
499
-
500
- ## Limitations
501
-
502
- ### Budget Enforcement Behavior
503
-
504
- **Important:**
505
-
506
- - **Local Monitoring Only**: Budgets defined in `json` configs or command-line flags are tracked locally by Zen.
507
- Zen cannot prevent the underlying CLI from consuming tokens beyond the limit in some cases.
508
- For example if a request is made when it is under budget, that single request may exceed the budget. In `block` mode the *next* request will be stopped.
509
- - **Budget Exceeded Behavior**:
510
- - `warn` mode: Zen logs warnings but continues execution
511
- - `block` mode: Zen prevents running new instances or halts in progress commands, depending on the nature of the budget config.
512
- - **Token Counting**: Budget calculations are based on estimates and may not match exact billing from Claude/Codex
513
-
514
- ### Target Audience and Use Cases
515
-
516
- Zen is designed for internal developer productivity and automation workflows and is *not* suitable for all use cases.
517
-
518
- It is generally expected that you already familiar with claude code
519
- in order to get the most value out of Zen.
520
-
521
- **✅ Supported Use Cases:**
522
- - Internal development workflows and automation
523
- - Parallel execution of development tasks
524
- - CI/CD integration for development teams
525
- - Budget and cost control for Claude
526
-
527
- ## Installation
528
-
529
- ### Default Method: pipx (Recommended for ALL Users)
530
-
531
- Pipx automatically handles PATH configuration and creates an isolated environment, preventing dependency conflicts.
532
-
533
- #### Step 1: Install pipx
534
- ```bash
535
- # Windows
536
- pip install --user pipx
537
- python -m pipx ensurepath
538
-
539
- # macOS
540
- brew install pipx
541
- pipx ensurepath
542
-
543
- # Linux (Ubuntu/Debian)
544
- sudo apt update
545
- sudo apt install pipx
546
- pipx ensurepath
547
-
548
- # Linux (Other)
549
- pip install --user pipx
550
- pipx ensurepath
551
- ```
552
-
553
- **Note:** Restart your terminal after running `pipx ensurepath`
554
-
555
- #### Step 2: Install zen
556
- ```bash
557
- # From PyPI
558
- pipx install netra-zen
559
-
560
- # For local development (editable mode)
561
- cd zen/
562
- pipx install --editable .
563
-
564
- # Verify installation
565
- zen --help
566
- ```
567
-
568
- ### Alternative: pip (Manual PATH Configuration Required)
569
-
570
- ⚠️ **Warning:** Using pip directly often results in PATH issues. We strongly recommend pipx instead.
571
-
572
- ```bash
573
- pip install netra-zen
574
-
575
- # If 'zen' command not found, you'll need to:
576
- # Option 1: Use Python module directly
577
- python -m zen_orchestrator --help
578
-
579
- # Option 2: Manually add to PATH (see Troubleshooting)
580
- ```
581
-
582
- ## Understanding the Model Column in Status Reports
583
-
584
- ### Model Column Behavior
585
-
586
- The **Model** column in Zen's status display shows the **actual model used** by Claude Code for each API response, not necessarily the model you configured in your settings.
587
-
588
- **Key Points:**
589
- - **Cost Tracking Value**: Knowing the actual model is critical for accurate cost calculation since different models have vastly different pricing (e.g., Opus costs 5x more than Sonnet)
590
- - **Dynamic Detection**: Zen automatically detects the model from Claude's API responses in real-time
591
-
592
- **Example Status Display:**
593
- ```
594
- ║ Status Name Model Duration Overall Tokens Budget
595
- ║ ✅ analyze-code 35sonnet 2m15s 45.2K 2.1K 85% used
596
- ║ 🏃 optimize-perf opus4 1m30s 12.8K 800 45% used
597
- ```
598
-
599
- This transparency helps you understand your actual AI spend and make informed decisions about model usage.
600
-
601
-
602
- ### Step 3: Generate with AI
603
-
604
- 1. Copy your customized prompt
605
- 2. Paste it into ChatGPT, Claude, or your preferred LLM
606
- 3. Save the generated JSON as `customer_feedback.json`
607
- 4. Run: `zen --config customer_feedback.json`
608
-
609
- ## Understanding Configuration Structure
610
-
611
- Every Zen configuration has the same basic structure:
612
-
613
- ```json
614
- {
615
- "// Description": "What this workflow accomplishes",
616
- "// Use Case": "When to use this configuration",
617
-
618
- "instances": [
619
- {
620
- "command": "/command || prompt",
621
- "permission_mode": "bypassPermissions", // Default
622
- "output_format": "stream-json", // Default
623
- "max_tokens_per_command": 12000, // Optional
624
- "allowed_tools": ["Read", "Write", "Edit", "Task"], // Optional
625
- // Other optional features
626
- }//,
627
- //{
628
- // next instance
629
- //}
630
- //... series of instances
631
- ]
632
- }
633
- ```
634
-
635
- ### Key Configuration Elements
636
-
637
- | Element | Purpose | Best Practice |
638
- |---------|---------|---------------|
639
- | `command` | Task specification | Can use existing /commands or any string literal input |
640
- | `max_tokens_per_command` | Token budget | Allocate based on complexity |
641
- | `allowed_tools` | Tool permissions | Grant minimal necessary tools |
642
-
643
- For Output Truncation control: `--max-console-lines` and `--max-line-length` parameters, or redirect output to files
644
-
645
- ### Scheduling
646
-
647
- Schedule to run later.
648
- This helps you get the most value out of your claude max subscription.
649
-
650
- ```bash
651
- # Start in 2 hours
652
- zen --config my_config.json --start-at "2h"
653
-
654
- # Start at specific time
655
- zen --config my_config.json --start-at "14:30"
656
-
657
- # Start in 30 minutes
658
- zen --config my_config.json --start-at "30m"
659
- ```
660
-
661
- ## Expected questions
662
-
663
- ### 1. Do I have to use /commands?
664
- - No. You can just put your string query (prompt) and it works the same.
665
- - It does seem to be a best practice though to version controlled `/commands`.
666
-
667
- ### 2. Does this replace using Claude command directly?
668
- - No. At least not yet fully.
669
- - As we primarily using structured commands, internally we see 80%+ of our usage through Zen.
670
- - Ad hoc questions or validating if a command is working as expected for now is better through Claude directly.
671
-
672
- ### 3. What does this assume?
673
- - You have claude code installed, authenticated, and configured already.
674
-
675
- ### 4. How do I know if it's working?
676
- - Each command returns fairly clear overall statuses.
677
- - Budget states etc. are logged.
678
- - You can also see the duration and token usage.
679
- - By default, each command outputs a truncated version of the output to the console.
680
- - You can optionally choose to save a report of all output to .json
681
- - Our usage is heavily integrated with github, we use git issues as the visual output
682
- and notification system for most work. This means regardless of where Zen is running
683
- you can see the results wherever you access git. This is as easy as adding `gh` instructions (the cli + token assumed to be present) to your commands.
684
-
685
- ### 5. Data privacy?
686
- At this moment no data is collected.
687
- Our intent is to add an optional system where non-PII usage data is sent to Netra for exclusively aggregated metadata level use to help make our spend management system better. (So you can get more from your AI spend!)
688
-
689
- ## 6. What about the UI/UX?
690
- There is a time and a place for wanting to have multiple windows and git trees open.
691
- Zen's intent is the opposite: make running `n` code clis more peaceful.
692
- Why activate your "giga-brain" when you can run one command instead?
693
-
694
-
695
- ## Zen --help
696
- ```zen --help```
697
- yields:
698
- ```
699
- usage: zen [-h] [--workspace WORKSPACE] [--config CONFIG] [--dry-run] [--list-commands] [--inspect-command INSPECT_COMMAND]
700
- [--output-format {json,stream-json}] [--timeout TIMEOUT] [--max-console-lines MAX_CONSOLE_LINES] [--quiet]
701
- [--startup-delay STARTUP_DELAY] [--max-line-length MAX_LINE_LENGTH] [--status-report-interval STATUS_REPORT_INTERVAL]
702
- [--start-at START_AT] [--overall-token-budget OVERALL_TOKEN_BUDGET] [--command-budget COMMAND_BUDGET]
703
- [--budget-enforcement-mode {warn,block}] [--disable-budget-visuals]
704
-
705
- Claude Code Instance Orchestrator
706
-
707
- options:
708
- -h, --help show this help message and exit
709
- --workspace WORKSPACE
710
- Workspace directory (default: current directory)
711
- --config CONFIG Custom instance configuration file
712
- --dry-run Show commands without running
713
- --list-commands List all available slash commands and exit
714
- --inspect-command INSPECT_COMMAND
715
- Inspect a specific slash command and exit
716
- --output-format {json,stream-json}
717
- Output format for Claude instances (default: stream-json)
718
- --timeout TIMEOUT Timeout in seconds for each instance (default: 10000)
719
- --max-console-lines MAX_CONSOLE_LINES
720
- Maximum recent lines to show per instance on console (default: 5)
721
- --quiet Minimize console output, show only errors and final summaries
722
- --startup-delay STARTUP_DELAY
723
- Delay in seconds between launching each instance (default: 5.0)
724
- --max-line-length MAX_LINE_LENGTH
725
- Maximum characters per line in console output (default: 500)
726
- --status-report-interval STATUS_REPORT_INTERVAL
727
- Seconds between rolling status reports (default: 5)
728
- --start-at START_AT Schedule orchestration to start at specific time. Examples: '2h' (2 hours from now), '30m' (30 minutes),
729
- '14:30' (2:30 PM today), '1am' (1 AM today/tomorrow)
730
- --overall-token-budget OVERALL_TOKEN_BUDGET
731
- Global token budget for the entire session.
732
- --command-budget COMMAND_BUDGET
733
- Per-command budget in format: '/command_name=limit'. Can be used multiple times.
734
- --budget-enforcement-mode {warn,block}
735
- Action to take when a budget is exceeded: 'warn' (log and continue) or 'block' (prevent new instances).
736
- --disable-budget-visuals
737
- Disable budget visualization in status reports
738
-
739
- ```
740
-
741
- ## Requirements
742
-
743
- - Python 3.8+
744
- - Claude Code CLI
745
- - Dependencies in requirements.txt
746
-
747
- ## Logging and Output
748
-
749
- - **Console Output**: All logs and execution results are displayed in the console
750
- - **No File Logging**: ZEN does not write logs to files by default
751
- - **Capturing Output**: To save execution logs, use output redirection:
752
- ```bash
753
- zen --config tasks.json > execution.log 2>&1
754
- ```
755
-
756
- ## Testing
757
-
758
- ```bash
759
- cd tests/
760
- python test_runner.py
761
- ```
762
-
763
- ## Basic Usage
764
-
765
- ### Command Execution
766
- Execute commands directly without config files:
767
- ```bash
768
- # Execute a single command directly
769
- zen "/my-existing-claude-command"
770
-
771
- # Execute with config (recommended usage pattern)
772
- zen --config /my-config.json
773
-
774
- # Execute with custom workspace
775
- zen "/analyze-code" --workspace ~/my-project
776
-
777
- # Execute with token budget
778
- zen "/complex-analysis" --overall-token-budget 5000
779
-
780
- # Execute with custom instance name
781
- zen "/debug-issue" --instance-name "debug-session"
782
-
783
- # Execute with session continuity
784
- zen "/optimize-performance" --session-id "perf-session-1"
785
-
786
- # Start in 2 hours
787
- zen --config my_config.json --start-at "2h"
788
-
789
- # Start at specific time
790
- zen --config my_config.json --start-at "14:30"
791
-
792
- ```
793
-
794
-
795
- ### Quick Test
796
- ```bash
797
- # List available commands (auto-detects workspace)
798
- zen --list-commands
799
-
800
- # Dry run to see what would be executed (auto-detects workspace)
801
- zen --dry-run
802
-
803
- # Run with default configuration (uses actual slash commands from workspace)
804
- zen
805
- ```
806
-
807
- ### Workspace Management
808
- ```bash
809
- # Auto-detect workspace (looks for project root with .git, .claude, etc.)
810
- zen --dry-run
811
-
812
- # Use specific workspace (override auto-detection)
813
- zen --workspace ~/projects/myapp
814
-
815
- # With custom timeout
816
- zen --timeout 300 --workspace ~/projects/myapp
817
- ```
818
-
819
- ### Token Budget Control
820
- ```bash
821
- # Set overall budget
822
- zen --overall-token-budget 100000
823
-
824
- # Set per-command budgets
825
- zen --command-budget "/analyze=50000" --command-budget "/optimize=30000"
826
-
827
- # Budget enforcement modes
828
- zen --budget-enforcement-mode block # Stop when exceeded
829
- zen --budget-enforcement-mode warn # Warn but continue
830
- ```
831
-
832
- ### Scheduled Execution
833
- ```bash
834
- # Start in 2 hours
835
- zen --start-at "2h"
836
-
837
- # Start at specific time
838
- zen --start-at "14:30" # 2:30 PM today
839
- zen --start-at "1am" # 1 AM tomorrow
840
- ```
841
-
842
- ### Execution Mode Precedence
843
- Zen supports three execution modes with clear precedence rules:
844
-
845
- 1. **Direct Command** (Highest Priority)
846
- ```bash
847
- zen "/analyze-code" # Executes direct command
848
- ```
849
-
850
- 2. **Config File** (Medium Priority)
851
- ```bash
852
- zen --config my-config.json # Uses config file
853
- ```
854
-
855
- 3. **Default Instances** (Lowest Priority)
856
- ```bash
857
- zen # Uses built-in default commands
858
- ```
859
-
860
- ## Other Features
861
-
862
- ### Parallel Execution Control
863
- ```bash
864
- # Control startup delay between instances
865
- zen --startup-delay 30.0 # seconds between launches
866
-
867
- # Limit console output
868
- zen --max-console-lines 10
869
- zen --max-line-length 200
870
- ```
871
-
872
- ### Output Formats
873
- ```bash
874
- # JSON output
875
- zen --output-format json
876
-
877
- # Stream JSON (default)
878
- zen --output-format stream-json
879
- ```
880
-
881
- ### Quiet Mode
882
- ```bash
883
- # Minimal output - only errors and summary
884
- zen --quiet
885
- ```
886
-
887
- ### Status Reporting
888
- ```bash
889
- # Change status report interval
890
- zen --status-report-interval 30 # Every 30 seconds
891
- ```
892
-
893
- ## Environment Variables
894
-
895
- ```bash
896
- # Set default workspace
897
- export ZEN_WORKSPACE="~/projects"
898
-
899
- # Set default config
900
- export ZEN_CONFIG="~/configs/zen-default.json"
901
-
902
- # Enable debug logging
903
- export ZEN_DEBUG="true"
904
- ```
905
-
906
- ## Troubleshooting
907
-
908
- ### Command not found
909
-
910
- #### If using pipx (recommended):
911
- ```bash
912
- # Ensure PATH is configured
913
- pipx ensurepath
914
-
915
- # Restart terminal, then verify
916
- zen --version
917
- ```
918
-
919
- ### Permission denied
920
- ```bash
921
- # Make sure scripts are executable
922
- chmod +x $(which zen)
923
- ```
924
-
925
- ### Module not found
926
- ```bash
927
- # Reinstall with dependencies
928
- pip install --force-reinstall netra-zen
929
- ```
930
-
931
- ## Getting Help
932
-
933
- ```bash
934
- # Show help
935
- zen --help
936
-
937
- # Inspect specific command
938
- zen --inspect-command /analyze
939
-
940
- # Visit documentation
941
- # https://github.com/netra-systems/zen
942
- ```
943
-
944
- ### Known Issues
945
-
946
- **Token Budget Accuracy:**
947
- - **Problem**: Budget calculations may not exactly match actual API billing
948
- - **Cause**: Estimates based on local token counting vs. server-side billing
949
- - **Workaround**: Use conservative budget limits and monitor actual usage through provider dashboards
950
-
951
- **Configuration File Validation:**
952
- - **Problem**: Limited validation of JSON configuration files
953
- - **Impact**: Invalid configurations may cause runtime errors
954
- - **Workaround**: Use `--dry-run` to validate configurations before execution
955
-
956
- **Resource Cleanup:**
957
- - **Problem**: Interrupted executions may leave background processes running
958
- - **Workaround**: Monitor system processes and manually terminate if necessary
959
- - **Planned Fix**: Improved signal handling and cleanup in future versions
960
-
961
- ## Example Configurations
962
-
963
- See the included example files:
964
- - `minimal_config.json` - Basic setup
965
- - `config_example.json` - Standard configuration
966
- - `netra_apex_tool_example.json` - Advanced integration
967
-
968
- ## Support
969
-
970
- - GitHub Issues: https://github.com/netra-systems/zen/issues
971
- - Documentation: https://github.com/netra-systems/zen/wiki
1
+ Metadata-Version: 2.4
2
+ Name: netra-zen
3
+ Version: 1.1.2
4
+ Summary: Multi-instance Claude orchestrator for parallel task execution
5
+ Home-page: https://github.com/netra-systems/zen
6
+ Author: Systems
7
+ Author-email: Netra Systems <pypi@netrasystems.ai>
8
+ License: MIT
9
+ Project-URL: Homepage, https://github.com/netra-systems/zen
10
+ Project-URL: Documentation, https://github.com/netra-systems/zen#readme
11
+ Project-URL: Repository, https://github.com/netra-systems/zen.git
12
+ Project-URL: Bug Tracker, https://github.com/netra-systems/zen/issues
13
+ Project-URL: Changelog, https://github.com/netra-systems/zen/blob/main/CHANGELOG.md
14
+ Keywords: claude,ai,orchestration,parallel,automation,llm,anthropic
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: Other/Proprietary License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.8
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
+ Classifier: Topic :: Software Development :: Quality Assurance
27
+ Classifier: Topic :: System :: Distributed Computing
28
+ Requires-Python: >=3.8
29
+ Description-Content-Type: text/markdown
30
+ License-File: LICENSE.md
31
+ Requires-Dist: PyYAML>=6.0
32
+ Requires-Dist: python-dateutil>=2.8.2
33
+ Requires-Dist: aiohttp>=3.8.0
34
+ Requires-Dist: websockets>=11.0
35
+ Requires-Dist: rich>=13.0.0
36
+ Requires-Dist: PyJWT>=2.8.0
37
+ Requires-Dist: psutil>=5.9.0
38
+ Requires-Dist: opentelemetry-sdk>=1.20.0
39
+ Requires-Dist: opentelemetry-exporter-gcp-trace>=1.6.0
40
+ Requires-Dist: google-cloud-trace>=1.11.0
41
+ Provides-Extra: dev
42
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
43
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
44
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
45
+ Requires-Dist: black>=23.0.0; extra == "dev"
46
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
47
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
48
+ Provides-Extra: netra
49
+ Requires-Dist: netraoptimizer>=1.0.0; extra == "netra"
50
+ Dynamic: author
51
+ Dynamic: home-page
52
+ Dynamic: license-file
53
+ Dynamic: requires-python
54
+
55
+ # Free more claude usage through optimization.
56
+
57
+ Extend your claude usage (all plans) for free with minimal effort and no risk.
58
+
59
+ It works by analyzing your usage logs for metadata optimizations. It is focused on the metadata not the semantics of the prompt, so no risk in drop of quality.
60
+
61
+ This is a micro startup effort, aiming to provide real value for individual devs in exchange for feedback. Our intent is to charge businesses for larger scale optimizations.
62
+
63
+ The process is simple. One time install, then one command. It analyzes your most recent log file and provides actionable items to update going forward to get the value of the optimizations. For best results, analyze one log file at a time with payloads under 1MB for focused, accurate analysis.
64
+
65
+ ## Quick start
66
+
67
+ 1. `pip install netra-zen`
68
+ 2. `zen --apex` # Logs are now sent by default
69
+ 3. Read the results and update claude settings, prompts, commands, etc. as needed to benefit
70
+
71
+ See detailed install below if needed.
72
+
73
+ ### Log Collection Options
74
+
75
+ The optimizer automatically analyzes your Claude Code usage logs to identify optimization opportunities. You can customize the behavior:
76
+
77
+ ```bash
78
+ # Send logs from the most recent file (default behavior)
79
+ zen --apex
80
+
81
+ # Send logs from a specific project
82
+ zen --apex --logs-project "my-project-name"
83
+
84
+ # Send logs from a custom location
85
+ zen --apex --logs-path "/path/to/.claude/Projects"
86
+
87
+ # Advanced: Send multiple files (use with caution)
88
+ zen --apex --logs-count 2
89
+ ```
90
+
91
+ **Important:**
92
+ - `--logs-count` default is **1** for current Alpha release limitations.
93
+ - For optimal analysis, use **1 log file at a time** and keep payload under 1MB
94
+ - Multiple log files can dilute the analysis and reduce accuracy
95
+ - Each file may contain many log entries
96
+ - The tool will display exactly how many entries from how many files are being sent
97
+
98
+ ## Example output
99
+ ![example](https://github.com/user-attachments/assets/94ed0180-9fed-4d76-ab69-657b7d3ab1b2)
100
+
101
+
102
+ ## Proof it works
103
+ ### Example savings on real world production git issue progressor task (complex claude code command)
104
+ This was just changing a few small lines on a 400 line command.
105
+ ![savings](https://github.com/user-attachments/assets/9298e7cc-4f15-4dc0-97e3-1f126757dde6)
106
+
107
+ ## Notes
108
+ - Have an optimization idea or area you want it to focus on? Create a git issue and we can add that to our evals.
109
+
110
+ ## Example output from single file
111
+ ```
112
+ zen --apex --logs-path /Users/user/.claude/projects/-Users-Desktop-netra-apex/7ac6d7ac-abc3-4903-a482-......-1.jsonl
113
+
114
+ SUCCESS: WebSocket connected successfully!
115
+
116
+ ============================================================
117
+ 📤 SENDING LOGS TO OPTIMIZER
118
+ ============================================================
119
+ Total Entries: 781
120
+ Files Read: 1
121
+ Payload Size: 5.52 MB
122
+
123
+ Files:
124
+ • 7ac6d7ac-abc3-4903-a482-.....jsonl (hash: 908dbc51, 781 entries)
125
+
126
+ Payload Confirmation:
127
+ 'jsonl_logs' key added to payload
128
+ First log entry timestamp: 2025-10-03T18:26:02.089Z
129
+ Last log entry timestamp: 2025-10-03T19:31:21.876Z
130
+ ============================================================
131
+
132
+ [11:32:55.190] [DEBUG] GOLDEN PATH TRACE: Prepared WebSocket payload for run_id=cli_20251008_113255_25048,
133
+ thread_id=cli_thread_f887c58e7759
134
+ [11:32:55.191] [DEBUG] ✓ TRANSMISSION PROOF: Payload contains 781 JSONL log entries in 'jsonl_logs' key
135
+ SUCCESS: Message sent with run_id: cli_20251008_113255_25048
136
+ Waiting 120 seconds for events...
137
+ Receiving events...
138
+ [11:32:55.284] [DEBUG] Listening for WebSocket events...
139
+ [11:32:55.284] [DEBUG] GOLDEN PATH TRACE: Event listener started after successful connection
140
+ [11:32:56.655] [DEBUG] WebSocket Event #1: raw_message_received
141
+ [11:32:56.657] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=connection_established
142
+ [11:32:56.658] [DEBUG] WebSocket Event #2: connection_established
143
+ [11:32:56] [CONN] Connected as: e2e-staging-2d677771
144
+ [11:33:01.364] [DEBUG] WebSocket Event #3: raw_message_received
145
+ [11:33:01.366] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=thread_created
146
+ [11:33:01.367] [DEBUG] WebSocket Event #4: thread_created
147
+ [11:33:01] [EVENT] thread_created: {"type": "thread_created", "payload": {"thread_id":
148
+ "thread_session_969_44184cce", "timestamp": 1759...
149
+ [11:33:02.901] [DEBUG] WebSocket Event #5: raw_message_received
150
+ [11:33:02.903] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
151
+ [11:33:02.904] [DEBUG] WebSocket Event #6: agent_started
152
+ [11:33:02] 🧠 Agent: netra-assistant started (run: run_sess...)
153
+ [11:33:04.744] [DEBUG] WebSocket Event #7: raw_message_received
154
+ [11:33:04.746] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
155
+ [11:33:04.747] [DEBUG] WebSocket Event #8: agent_started
156
+ [11:33:04] 🧠 Agent: netra-assistant started (run: run_sess...)
157
+ [11:33:06.366] [DEBUG] WebSocket Event #9: raw_message_received
158
+ [11:33:06.368] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
159
+ [11:33:06.369] [DEBUG] WebSocket Event #10: agent_started
160
+ [11:33:06] 🧠 Agent: MessageHandler started (run: run_sess...)
161
+ [11:33:14.781] [DEBUG] WebSocket Event #11: raw_message_received
162
+ [11:33:14.783] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_started
163
+ [11:33:14.784] [DEBUG] WebSocket Event #12: agent_started
164
+ [11:33:14] 🧠 Agent: claude_code_optimizer started (run: run_sess...)
165
+ [11:33:23.241] [DEBUG] WebSocket Event #13: raw_message_received
166
+ [11:33:23.243] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_thinking
167
+ [11:33:23.244] [DEBUG] WebSocket Event #14: agent_thinking
168
+ [11:33:23] 💭 Thinking: Preparing optimization prompt
169
+ ⠹ 💭 Preparing optimization prompt[11:34:27.586] [DEBUG] WebSocket Event #15: raw_message_received
170
+ [11:34:27.588] [DEBUG] GOLDEN PATH TRACE: Parsed WebSocket event type=agent_completed
171
+ [11:34:27.589] [DEBUG] WebSocket Event #16: agent_completed
172
+ 💭 Preparing optimization prompt
173
+ [11:34:27] 🧠 Agent Completed: claude_code_optimizer (run: run_sess...) - {"status": "done", "result":
174
+ {"optimizations": [{"issue": "Repeated Full File Read", "evidence": "Th...
175
+ ╭────────────────────────────────── Final Agent Result - Optimization Pointers ──────────────────────────────────╮
176
+ { │
177
+ "status": "done",
178
+ │ "result": {
179
+ "optimizations": [
180
+ {
181
+ "issue": "Repeated Full File Read",
182
+ │ "evidence": "The file `api/src/routes/user.js` was read in its entirety using `cat` twice. The model
183
+ read it once to understand the code, but then read the entire file again later to re-confirm a detail it had
184
+ forgotten.",
185
+ "token_waste": "High (~2.5k tokens). The entire content of the 250-line file was added to the context
186
+ a second time, providing no new information.",
187
+ "fix": "The model should retain the context of files it has already read within the same task. If it
188
+ needs to re-check a specific detail, it should use a targeted tool like `grep` or `read_lines` (e.g., `grep -C
189
+ 5 'findUser' api/src/routes/user.js`) instead of re-reading the entire file.",
190
+ "ideal prompt": "The user profile page isn't loading the user's name. The API endpoint is in
191
+ `api/src/routes/user.js` and it calls the `findUser` function from `api/src/db/utils.js`. Please investigate
192
+ the data flow between these two files and fix the issue.",
193
+ "priority": "high"
194
+ },
195
+ {
196
+ "issue": "Excessive Context Gathering",
197
+ │ "evidence": "The `cat` command was used on two large files (`user.js` and `utils.js`), ingesting a
198
+ total of 400 lines of code into the context. The actual bug was confined to a small 5-line function within
199
+ `utils.js`.",
200
+ "token_waste": "High (~4k tokens). Most of the file content was irrelevant to the specific task of
201
+ fixing the `findUser` function's return value.",
202
+ "fix": "Instead of `cat`, the model should use more precise tools to gather context. After identifying
203
+ the relevant function with `grep`, it could have used a command like `read_lines('api/src/db/utils.js',
204
+ start_line, end_line)` or `grep -A 10 'const findUser' api/src/db/utils.js` to read only the function's
205
+ definition and its immediate surroundings.",
206
+ "ideal prompt": "The `findUser` function in `api/src/db/utils.js` is not returning the user's name
207
+ field. Please add it to the return object.",
208
+ "priority": "high"
209
+ },
210
+ {
211
+ "issue": "Inefficient Project-Wide Search",
212
+ │ "evidence": "A recursive grep (`grep -r \"findUser\" .`) was used to find the definition of
213
+ `findUser`. While effective, this can be slow and return a lot of irrelevant matches (like comments, logs,
214
+ etc.) in a large codebase, consuming tokens in the tool output.",
215
+ "token_waste": "Medium (~500 tokens). The `grep` returned multiple matches, including the call site
216
+ which was already known. In a larger project, this could return dozens of matches.",
217
+ "fix": "If the project structure is conventional, a more targeted search would be better. For example,
218
+ knowing `db` utilities are likely in a `db` or `utils` directory, a command like `grep 'findUser'
219
+ api/src/db/*.js` would be more direct and produce less noise.",
220
+ "ideal prompt": "The `findUser` function, defined in the `api/src/db/` directory, seems to be causing
221
+ a bug. Can you find its definition and check what it returns?",
222
+ "priority": "low"
223
+ }
224
+ ],
225
+ "summary": {
226
+ "total_issues": 3,
227
+ │ "estimated_savings": "~7k tokens",
228
+ │ "top_priority": "Avoid repeated full file reads. The model should trust its context or use targeted
229
+ tools like `grep` to refresh specific details instead of re-ingesting entire files."
230
+ }
231
+ },
232
+ "message": "Claude Code optimization analysis complete"
233
+ }
234
+ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
235
+
236
+ 📊 Received 8 events
237
+ ```
238
+
239
+ # Another example
240
+ ```
241
+ "issue": "Confused execution path and backtracking", │
242
+
243
+ "evidence": "The model initially assumes a JavaScript/TypeScript frontend based on the term
244
+ │ \"client side\", leading to incorrect file searches. After realizing it's a Python project, it gets stuck
245
+ repeatedly grepping `scripts/agent_cli.py` and requires multiple user interventions to be redirected to
246
+ │ the actual root cause in `zen_orchestrator.py` and `zen/telemetry/apex_telemetry.py`", ... │
247
+ │ "token_waste": "8000-10000", │
248
+ │ "fix": "When an initial search term (e.g., 'ultrathink') fails, the model should prioritize │
249
+ │ understanding the project's overall structure and language (`ls -R` or `find . -type f | head -n 20`) │
250
+ before making assumptions. For regressions, `git log` should be used earlier in the process to identify │
251
+ recent, relevant changes that could have introduced the bug.",
252
+
253
+ │ "ideal prompt": "There's a regression where events are batched instead of streamed. The user │
254
+ mentioned 'client side ultrathink', but that could be a red herring. Start by checking the project │
255
+ structure and language, then review the git history for recent changes related to event handling, │
256
+ │ streaming, telemetry, or subprocess execution before deep-diving into code.", │
257
+ │ "priority": "high" │
258
+ │ }
259
+ ```
260
+
261
+ # Advanced features & detailed install guide
262
+
263
+ In addition to optimizing your costs and latency,
264
+ you can control budgets and other advanced features.
265
+
266
+ ### Orchestrator
267
+
268
+ Orchestrator allows you to:
269
+ - Orchestrator runs multiple Code CLI instances for peaceful parallel task execution.
270
+ - Run multiple headless Claude Code CLI instances simultaneously.
271
+ - Calm unified results (status, time, token usage)
272
+ - Relax **"5-hour limit reached"** lockout fears with easy token budget limits
273
+ - Get more value out of your Claude MAX subscription
274
+ with scheduling features. (`--run-at "2am"`)
275
+ - Learn more about how Claude Code uses tools and other inner workings
276
+ - Control usage and budget for groups of work or per command
277
+
278
+ Example portion of status report:
279
+ ```
280
+ ╔═══ STATUS REPORT [14:25:10] ═══╗
281
+ ║ Total: 5 instances
282
+ ║ Running: 3, Completed: 2, Failed: 0
283
+ ║ Tokens: 32.1K total | Tools: 15
284
+ 💰 Cost: $0.0642 total
285
+
286
+ TOKEN BUDGET STATUS
287
+ Overall: [████████████----] 75% 32.1K/43.0K
288
+
289
+ ║ Status Name Duration Tokens
290
+ ║ ──────── ───────────────── ─────── ──────
291
+ ║ ✅ security-reviewer 2m15s 8.5K
292
+ ║ ✅ performance-analyzer 1m42s 7.2K
293
+ ║ 🏃 architecture-reviewer 1m18s 6.5K
294
+ ║ 🏃 test-coverage-analyst 0m45s 4.8K
295
+ ║ ⏳ quality-synthesizer queued 0K
296
+ ╚════════════════════════════════════════════╝
297
+ ```
298
+
299
+ ## Example Start
300
+ ```
301
+ zen
302
+ ```
303
+
304
+ ```
305
+ +=== STATUS REPORT [14:47:39] ===+
306
+ | Total: 2 instances
307
+ | Running: 2, Completed: 0, Failed: 0, Pending: 0
308
+ | Tokens: 0 total, 0 cached | Median: 0 | Tools: 0
309
+ | 💰 Cost: $0.0000 total, $0.0000 avg/instance | Pricing: Claude compliant
310
+ |
311
+ | TOKEN BUDGET STATUS |
312
+ | Overall: [--------------------] 0% 0/10.0K
313
+ | Command Budgets:
314
+ | /analyze-repository [--------------------] 0% 0/5.0K
315
+ | /README [--------------------] 0% 0/1.0K
316
+ |
317
+ | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
318
+ | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
319
+ | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
320
+ | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
321
+ | 🏃 analyze-repo opus4 5.1s 0 0 0 0 0 0/5.0K
322
+ | 🏃 help-overview sonnet4 0.0s 0 0 0 0 0 0/1.0K
323
+ +================================+
324
+ ```
325
+
326
+ ## Budget Warning Only
327
+ ```
328
+ zen --overall-token-budget 10000
329
+ ```
330
+ ```
331
+ +=== STATUS REPORT [14:47:44] ===+
332
+ | Total: 2 instances
333
+ | Running: 2, Completed: 0, Failed: 0, Pending: 0
334
+ | Tokens: 32.2K total, 32.2K cached | Median: 32.2K | Tools: 1
335
+ | 💰 Cost: $0.0818 total, $0.0409 avg/instance | Pricing: Claude compliant
336
+ |
337
+ | TOKEN BUDGET STATUS |
338
+ | Overall: [####################] 100% 32.2K/10.0K
339
+ | Command Budgets:
340
+ | /analyze-repository [####################] 100% 32.2K/5.0K
341
+ | /README [--------------------] 0% 0/1.0K
342
+ |
343
+ | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
344
+ | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
345
+ | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
346
+ | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
347
+ | 🏃 analyze-repo 35sonnet 10.1s 32.2K 5 20.9K 11.4K 1 32.2K/5.0K
348
+ | 🏃 help-overview opus4 5.0s 0 0 0 0 0 0/1.0K
349
+ +================================+
350
+
351
+ +=== TOOL USAGE DETAILS ===+
352
+ | Tool Name Uses Tokens Cost ($) Used By
353
+ | -------------------- -------- ---------- ---------- -----------------------------------
354
+ | Bash 1 33 0.0001 analyze-repo(1 uses, 33 tok)
355
+ | -------------------- -------- ---------- ---------- -----------------------------------
356
+ | TOTAL 1 33 0.0001
357
+ +===============================================================================================+
358
+ ```
359
+
360
+ ## Budget Block
361
+ ```
362
+ zen --overall-token-budget 10000 --budget-enforcement-mode block
363
+ ```
364
+ ```
365
+ 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - 💰 BUDGET UPDATE [analyze-repo]: Recording 32240 tokens for command '/analyze-repository'
366
+ 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - 📊 BUDGET STATE [analyze-repo]: /analyze-repository now at 32240/5000 tokens (644.8%)
367
+ 2025-09-18 14:50:42,050 - zen_orchestrator - ERROR - 🚫 🔴 RUNTIME TERMINATION: Runtime budget violation for analyze-repo: Overall budget exceeded: 32240/10000 tokens
368
+ 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - Terminating instance analyze-repo (PID: 88916): Terminated due to budget violation - Overall budget exceeded: 32240/10000 tokens
369
+ 2025-09-18 14:50:42,050 - zen_orchestrator - INFO - Sent SIGTERM to analyze-repo (PID: 88916)
370
+ ```
371
+
372
+ ```
373
+ +=== FINAL STATUS [14:50:57] ===+
374
+ | Total: 2 instances
375
+ | Running: 0, Completed: 0, Failed: 2, Pending: 0
376
+ | Tokens: 85.6K total, 85.2K cached | Median: 42.8K | Tools: 1
377
+ | 💰 Cost: $0.0889 total, $0.0444 avg/instance | Pricing: Claude compliant
378
+ |
379
+ | TOKEN BUDGET STATUS |
380
+ | Overall: [####################] 100% 85.6K/10.0K
381
+ | Command Budgets:
382
+ | /analyze-repository [####################] 100% 48.4K/5.0K
383
+ | /README [####################] 100% 37.2K/1.0K
384
+ |
385
+ | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
386
+ | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
387
+ | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
388
+ | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
389
+ | ❌ analyze-repo sonnet4 22.5s 48.4K 31 16.1K 32.2K 1 48.4K/5.0K
390
+ | ❌ help-overview 35sonnet 16.2s 37.2K 422 0 36.8K 0 37.2K/1.0K
391
+ +===============================+
392
+
393
+ +=== TOOL USAGE DETAILS ===+
394
+ | Tool Name Uses Tokens Cost ($) Used By
395
+ | -------------------- -------- ---------- ---------- -----------------------------------
396
+ | Task 1 348 0.0010 analyze-repo(1 uses, 348 tok)
397
+ | -------------------- -------- ---------- ---------- -----------------------------------
398
+ | TOTAL 1 348 0.0010
399
+ +===============================================================================================+
400
+ ```
401
+
402
+ # Example Start At
403
+ ```
404
+ zen --start-at "2am"
405
+ ```
406
+
407
+ ```
408
+ ...
409
+ 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Added instance: analyze-repo - Analyze the repository structure and codebase
410
+ 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Added instance: help-overview - Show project README and overview information
411
+
412
+ 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Orchestration scheduled to start at: 2025-09-19 02:00:00
413
+ 2025-09-18 14:54:29,863 - zen_orchestrator - INFO - Waiting 39930.1 seconds (11.1 hours) until start time...
414
+ ```
415
+
416
+ # Example Command
417
+ **Assumes you have a claude command /runtests**
418
+ ```
419
+ zen "/runtests"
420
+ ```
421
+ ```
422
+ ...
423
+ 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Added instance: direct-runtests-3337c2c5 - Direct execution of /runtests
424
+ 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Starting Claude Code instance orchestration
425
+ 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Starting 1 instances with 5.0s delay between launches (timeout: 10000s each)
426
+ 2025-09-18 14:56:18,478 - zen_orchestrator - INFO - Now starting instance 'direct-runtests-3337c2c5' (after 0.0s delay)
427
+
428
+ ```
429
+ # Example Config (Recommended Usage)
430
+
431
+ Your JSON file as `path\my_config.json`
432
+ ```JSON
433
+ {
434
+ "instances": [
435
+ {
436
+ "name": "analyze-repository",
437
+ "command": "/analyze-repository; Spawn three subagents to understand how the information at this website is used in the zen directory. https://docs.claude.com/en/docs/about-claude/pricing#tool-use-pricing.",
438
+ "description": "Reads and understands the required portion of the repository",
439
+ "permission_mode": "bypassPermissions",
440
+ "output_format": "stream-json",
441
+ "max_tokens_per_command": 5000
442
+ }
443
+ ]
444
+ }
445
+ ```
446
+ ```
447
+ zen --config path\my_config.json
448
+ ```
449
+
450
+ ```
451
+ ...
452
+
453
+ 2025-09-18 15:00:09,645 - zen_orchestrator - INFO - Loading config from config_example.json
454
+
455
+ 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - 🎯 Token transparency pricing engine enabled - Claude pricing compliance active
456
+
457
+ 2025-09-18 15:00:09,657 - zen_orchestrator - WARNING - Command '/analyze-repository; Spawn three subagents to understand how the information at this website is used in the zen directory. https://docs.claude.com/en/docs/about-claude/pricing#tool-use-pricing.' not found in available commands
458
+
459
+ 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - Available commands: /clear, /compact, /help
460
+
461
+ 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - Added instance: analyze-repository - Reads and understands the required portion of the repository
462
+
463
+ 2025-09-18 15:00:09,657 - zen_orchestrator - INFO - Starting Claude Code instance orchestration
464
+
465
+ 2025-09-18 15:00:09,659 - zen_orchestrator - INFO - Starting 1 instances with 5.0s delay between launches (timeout: 10000s each)
466
+
467
+ 2025-09-18 15:00:09,659 - zen_orchestrator - INFO - Now starting instance 'analyze-repository' (after 0.0s delay)
468
+
469
+ 2025-09-18 15:00:09,659 - zen_orchestrator - INFO - Starting instance: analyze-repository
470
+
471
+ 2025-09-18 15:00:09,665 - zen_orchestrator - INFO - Command: claude.CMD -p /analyze-repository; Spawn three subagents to understand how the information at this website is used in the zen directory. https://docs.claude.com/en/docs/about-claude/pricing#tool-use-pricing. --output-format=stream-json --permission-mode=bypassPermissions --verbose
472
+
473
+ 2025-09-18 15:00:09,738 - zen_orchestrator - INFO - Permission mode: bypassPermissions (Platform: Windows)
474
+ 2025-09-18 15:00:09,746 - zen_orchestrator - INFO - Instance analyze-repository started with PID 672
475
+
476
+ +=== STATUS REPORT [15:00:14] ===+
477
+ | Total: 1 instances
478
+ | Running: 1, Completed: 0, Failed: 0, Pending: 0
479
+ | Tokens: 0 total, 0 cached | Median: 0 | Tools: 0
480
+ | 💰 Cost: $0.0000 total, $0.0000 avg/instance | Pricing: Claude compliant
481
+ |
482
+ | 📝 Model shows actual Claude model used (critical for accurate cost tracking)
483
+ | 💡 Tip: Model may differ from your config - Claude routes requests intelligently
484
+ | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
485
+ | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
486
+ | 🏃 analyze-repository opus4 5.1s 0 0 0 0 0 -
487
+ +================================+
488
+
489
+
490
+ +=== STATUS REPORT [15:00:19] ===+
491
+ | Total: 1 instances
492
+ | Running: 1, Completed: 0, Failed: 0, Pending: 0
493
+ | Tokens: 14.7K total, 14.7K cached | Median: 14.7K | Tools: 0
494
+ | 💰 Cost: $0.0798 total, $0.0798 avg/instance | Pricing: Claude compliant
495
+ | Status Name Model Duration Overall Tokens Cache Cr Cache Rd Tools Budget
496
+ | -------- ------------------------------ ---------- ---------- -------- -------- -------- -------- ------ ----------
497
+ | 🏃 analyze-repository opus4 10.1s 14.7K 6 3.3K 11.4K 0 -
498
+ +================================+
499
+
500
+ ```
501
+
502
+
503
+ ## Inspiration and background
504
+ While developing Netra Apex (commercial product)
505
+ our team has been running 100s of parallel claude code instances.
506
+ During that process we got annoyed at the "cognitive overhead"
507
+ of each having 10s of terminals open per machine and scrolling mountains of text.
508
+ Did the `/command` work or not?
509
+
510
+ What started as a simple way to make that process more peaceful turned into something we believe will be useful to the community.
511
+
512
+ Further, as usage limits become more restrictive, getting up at odd hours just to feed the beast got old fast. So we added scheduling to run it at pre-defined times.
513
+
514
+ Surprisingly, the duration that a command ran and it's presumed difficulty, often had little correlation with actual token usage.
515
+ "Simple" git operations would sometimes eat 10x as many as complex issue resolution commands.
516
+
517
+ The market is moving quickly, codex is getting better and other Code CLIs are coming. How effective a code factory is matters. This V1 alpha is just the start of codifying code CLI dev practices and progressing from alchemy to engineering.
518
+
519
+ For more power, try Zen with Netra Apex for the most effective usage and control of business AI spend.
520
+
521
+ ## Limitations
522
+
523
+ ### Budget Enforcement Behavior
524
+
525
+ **Important:**
526
+
527
+ - **Local Monitoring Only**: Budgets defined in `json` configs or command-line flags are tracked locally by Zen.
528
+ Zen cannot prevent the underlying CLI from consuming tokens beyond the limit in some cases.
529
+ For example if a request is made when it is under budget, that single request may exceed the budget. In `block` mode the *next* request will be stopped.
530
+ - **Budget Exceeded Behavior**:
531
+ - `warn` mode: Zen logs warnings but continues execution
532
+ - `block` mode: Zen prevents running new instances or halts in progress commands, depending on the nature of the budget config.
533
+ - **Token Counting**: Budget calculations are based on estimates and may not match exact billing from Claude/Codex
534
+
535
+ ### Target Audience and Use Cases
536
+
537
+ Zen is designed for internal developer productivity and automation workflows and is *not* suitable for all use cases.
538
+
539
+ It is generally expected that you already familiar with claude code
540
+ in order to get the most value out of Zen.
541
+
542
+ **✅ Supported Use Cases:**
543
+ - Internal development workflows and automation
544
+ - Parallel execution of development tasks
545
+ - CI/CD integration for development teams
546
+ - Budget and cost control for Claude
547
+
548
+ ## Installation
549
+
550
+ ### Default Method: pipx (Recommended for ALL Users)
551
+
552
+ Pipx automatically handles PATH configuration and creates an isolated environment, preventing dependency conflicts.
553
+
554
+ #### Step 1: Install pipx
555
+ ```bash
556
+ # Windows
557
+ pip install --user pipx
558
+ python -m pipx ensurepath
559
+
560
+ # macOS
561
+ brew install pipx
562
+ pipx ensurepath
563
+
564
+ # Linux (Ubuntu/Debian)
565
+ sudo apt update
566
+ sudo apt install pipx
567
+ pipx ensurepath
568
+
569
+ # Linux (Other)
570
+ pip install --user pipx
571
+ pipx ensurepath
572
+ ```
573
+
574
+ **Note:** Restart your terminal after running `pipx ensurepath`
575
+
576
+ #### Step 2: Install zen
577
+ ```bash
578
+ # From PyPI
579
+ pipx install netra-zen
580
+
581
+ # For local development (editable mode)
582
+ cd zen/
583
+ pipx install --editable .
584
+
585
+ # Verify installation
586
+ zen --help
587
+ ```
588
+
589
+ ### Alternative: pip (Manual PATH Configuration Required)
590
+
591
+ ⚠️ **Warning:** Using pip directly often results in PATH issues. We strongly recommend pipx instead.
592
+
593
+ ```bash
594
+ pip install netra-zen
595
+
596
+ # If 'zen' command not found, you'll need to:
597
+ # Option 1: Use Python module directly
598
+ python -m zen_orchestrator --help
599
+
600
+ # Option 2: Manually add to PATH (see Troubleshooting)
601
+ ```
602
+
603
+ ## Understanding the Model Column in Status Reports
604
+
605
+ ### Model Column Behavior
606
+
607
+ The **Model** column in Zen's status display shows the **actual model used** by Claude Code for each API response, not necessarily the model you configured in your settings.
608
+
609
+ **Key Points:**
610
+ - **Cost Tracking Value**: Knowing the actual model is critical for accurate cost calculation since different models have vastly different pricing (e.g., Opus costs 5x more than Sonnet)
611
+ - **Dynamic Detection**: Zen automatically detects the model from Claude's API responses in real-time
612
+
613
+ **Example Status Display:**
614
+ ```
615
+ Status Name Model Duration Overall Tokens Budget
616
+ ✅ analyze-code 35sonnet 2m15s 45.2K 2.1K 85% used
617
+ ║ 🏃 optimize-perf opus4 1m30s 12.8K 800 45% used
618
+ ```
619
+
620
+ This transparency helps you understand your actual AI spend and make informed decisions about model usage.
621
+
622
+
623
+ ### Step 3: Generate with AI
624
+
625
+ 1. Copy your customized prompt
626
+ 2. Paste it into ChatGPT, Claude, or your preferred LLM
627
+ 3. Save the generated JSON as `customer_feedback.json`
628
+ 4. Run: `zen --config customer_feedback.json`
629
+
630
+ ## Understanding Configuration Structure
631
+
632
+ Every Zen configuration has the same basic structure:
633
+
634
+ ```json
635
+ {
636
+ "// Description": "What this workflow accomplishes",
637
+ "// Use Case": "When to use this configuration",
638
+
639
+ "instances": [
640
+ {
641
+ "command": "/command || prompt",
642
+ "permission_mode": "bypassPermissions", // Default
643
+ "output_format": "stream-json", // Default
644
+ "max_tokens_per_command": 12000, // Optional
645
+ "allowed_tools": ["Read", "Write", "Edit", "Task"], // Optional
646
+ // Other optional features
647
+ }//,
648
+ //{
649
+ // next instance
650
+ //}
651
+ //... series of instances
652
+ ]
653
+ }
654
+ ```
655
+
656
+ ### Key Configuration Elements
657
+
658
+ | Element | Purpose | Best Practice |
659
+ |---------|---------|---------------|
660
+ | `command` | Task specification | Can use existing /commands or any string literal input |
661
+ | `max_tokens_per_command` | Token budget | Allocate based on complexity |
662
+ | `allowed_tools` | Tool permissions | Grant minimal necessary tools |
663
+
664
+ For Output Truncation control: `--max-console-lines` and `--max-line-length` parameters, or redirect output to files
665
+
666
+ ### Scheduling
667
+
668
+ Schedule to run later.
669
+ This helps you get the most value out of your claude max subscription.
670
+
671
+ ```bash
672
+ # Start in 2 hours
673
+ zen --config my_config.json --start-at "2h"
674
+
675
+ # Start at specific time
676
+ zen --config my_config.json --start-at "14:30"
677
+
678
+ # Start in 30 minutes
679
+ zen --config my_config.json --start-at "30m"
680
+ ```
681
+
682
+ ## Expected questions
683
+
684
+ ### 1. Do I have to use /commands?
685
+ - No. You can just put your string query (prompt) and it works the same.
686
+ - It does seem to be a best practice though to version controlled `/commands`.
687
+
688
+ ### 2. Does this replace using Claude command directly?
689
+ - No. At least not yet fully.
690
+ - As we primarily using structured commands, internally we see 80%+ of our usage through Zen.
691
+ - Ad hoc questions or validating if a command is working as expected for now is better through Claude directly.
692
+
693
+ ### 3. What does this assume?
694
+ - You have claude code installed, authenticated, and configured already.
695
+
696
+ ### 4. How do I know if it's working?
697
+ - Each command returns fairly clear overall statuses.
698
+ - Budget states etc. are logged.
699
+ - You can also see the duration and token usage.
700
+ - By default, each command outputs a truncated version of the output to the console.
701
+ - You can optionally choose to save a report of all output to .json
702
+ - Our usage is heavily integrated with github, we use git issues as the visual output
703
+ and notification system for most work. This means regardless of where Zen is running
704
+ you can see the results wherever you access git. This is as easy as adding `gh` instructions (the cli + token assumed to be present) to your commands.
705
+
706
+ ### 5. Data privacy?
707
+ At this moment no data is collected.
708
+ Our intent is to add an optional system where non-PII usage data is sent to Netra for exclusively aggregated metadata level use to help make our spend management system better. (So you can get more from your AI spend!)
709
+
710
+ ## 6. What about the UI/UX?
711
+ There is a time and a place for wanting to have multiple windows and git trees open.
712
+ Zen's intent is the opposite: make running `n` code clis more peaceful.
713
+ Why activate your "giga-brain" when you can run one command instead?
714
+
715
+
716
+ ## Zen --help
717
+ ```zen --help```
718
+ yields:
719
+ ```
720
+ usage: zen [-h] [--workspace WORKSPACE] [--config CONFIG] [--dry-run] [--list-commands] [--inspect-command INSPECT_COMMAND]
721
+ [--output-format {json,stream-json}] [--timeout TIMEOUT] [--max-console-lines MAX_CONSOLE_LINES] [--quiet]
722
+ [--startup-delay STARTUP_DELAY] [--max-line-length MAX_LINE_LENGTH] [--status-report-interval STATUS_REPORT_INTERVAL]
723
+ [--start-at START_AT] [--overall-token-budget OVERALL_TOKEN_BUDGET] [--command-budget COMMAND_BUDGET]
724
+ [--budget-enforcement-mode {warn,block}] [--disable-budget-visuals]
725
+
726
+ Claude Code Instance Orchestrator
727
+
728
+ options:
729
+ -h, --help show this help message and exit
730
+ --workspace WORKSPACE
731
+ Workspace directory (default: current directory)
732
+ --config CONFIG Custom instance configuration file
733
+ --dry-run Show commands without running
734
+ --list-commands List all available slash commands and exit
735
+ --inspect-command INSPECT_COMMAND
736
+ Inspect a specific slash command and exit
737
+ --output-format {json,stream-json}
738
+ Output format for Claude instances (default: stream-json)
739
+ --timeout TIMEOUT Timeout in seconds for each instance (default: 10000)
740
+ --max-console-lines MAX_CONSOLE_LINES
741
+ Maximum recent lines to show per instance on console (default: 5)
742
+ --quiet Minimize console output, show only errors and final summaries
743
+ --startup-delay STARTUP_DELAY
744
+ Delay in seconds between launching each instance (default: 5.0)
745
+ --max-line-length MAX_LINE_LENGTH
746
+ Maximum characters per line in console output (default: 500)
747
+ --status-report-interval STATUS_REPORT_INTERVAL
748
+ Seconds between rolling status reports (default: 5)
749
+ --start-at START_AT Schedule orchestration to start at specific time. Examples: '2h' (2 hours from now), '30m' (30 minutes),
750
+ '14:30' (2:30 PM today), '1am' (1 AM today/tomorrow)
751
+ --overall-token-budget OVERALL_TOKEN_BUDGET
752
+ Global token budget for the entire session.
753
+ --command-budget COMMAND_BUDGET
754
+ Per-command budget in format: '/command_name=limit'. Can be used multiple times.
755
+ --budget-enforcement-mode {warn,block}
756
+ Action to take when a budget is exceeded: 'warn' (log and continue) or 'block' (prevent new instances).
757
+ --disable-budget-visuals
758
+ Disable budget visualization in status reports
759
+
760
+ ```
761
+
762
+ ## Requirements
763
+
764
+ - Python 3.8+
765
+ - Claude Code CLI
766
+ - Dependencies in requirements.txt
767
+
768
+ ## Logging and Output
769
+
770
+ - **Console Output**: All logs and execution results are displayed in the console
771
+ - **No File Logging**: ZEN does not write logs to files by default
772
+ - **Capturing Output**: To save execution logs, use output redirection:
773
+ ```bash
774
+ zen --config tasks.json > execution.log 2>&1
775
+ ```
776
+
777
+ ## Testing
778
+
779
+ ```bash
780
+ cd tests/
781
+ python test_runner.py
782
+ ```
783
+
784
+ ## Basic Usage
785
+
786
+ ### Command Execution
787
+ Execute commands directly without config files:
788
+ ```bash
789
+ # Execute a single command directly
790
+ zen "/my-existing-claude-command"
791
+
792
+ # Execute with config (recommended usage pattern)
793
+ zen --config /my-config.json
794
+
795
+ # Execute with custom workspace
796
+ zen "/analyze-code" --workspace ~/my-project
797
+
798
+ # Execute with token budget
799
+ zen "/complex-analysis" --overall-token-budget 5000
800
+
801
+ # Execute with custom instance name
802
+ zen "/debug-issue" --instance-name "debug-session"
803
+
804
+ # Execute with session continuity
805
+ zen "/optimize-performance" --session-id "perf-session-1"
806
+
807
+ # Start in 2 hours
808
+ zen --config my_config.json --start-at "2h"
809
+
810
+ # Start at specific time
811
+ zen --config my_config.json --start-at "14:30"
812
+
813
+ ```
814
+
815
+
816
+ ### Quick Test
817
+ ```bash
818
+ # List available commands (auto-detects workspace)
819
+ zen --list-commands
820
+
821
+ # Dry run to see what would be executed (auto-detects workspace)
822
+ zen --dry-run
823
+
824
+ # Run with default configuration (uses actual slash commands from workspace)
825
+ zen
826
+ ```
827
+
828
+ ### Workspace Management
829
+ ```bash
830
+ # Auto-detect workspace (looks for project root with .git, .claude, etc.)
831
+ zen --dry-run
832
+
833
+ # Use specific workspace (override auto-detection)
834
+ zen --workspace ~/projects/myapp
835
+
836
+ # With custom timeout
837
+ zen --timeout 300 --workspace ~/projects/myapp
838
+ ```
839
+
840
+ ### Token Budget Control
841
+ ```bash
842
+ # Set overall budget
843
+ zen --overall-token-budget 100000
844
+
845
+ # Set per-command budgets
846
+ zen --command-budget "/analyze=50000" --command-budget "/optimize=30000"
847
+
848
+ # Budget enforcement modes
849
+ zen --budget-enforcement-mode block # Stop when exceeded
850
+ zen --budget-enforcement-mode warn # Warn but continue
851
+ ```
852
+
853
+ ### Scheduled Execution
854
+ ```bash
855
+ # Start in 2 hours
856
+ zen --start-at "2h"
857
+
858
+ # Start at specific time
859
+ zen --start-at "14:30" # 2:30 PM today
860
+ zen --start-at "1am" # 1 AM tomorrow
861
+ ```
862
+
863
+ ### Execution Mode Precedence
864
+ Zen supports three execution modes with clear precedence rules:
865
+
866
+ 1. **Direct Command** (Highest Priority)
867
+ ```bash
868
+ zen "/analyze-code" # Executes direct command
869
+ ```
870
+
871
+ 2. **Config File** (Medium Priority)
872
+ ```bash
873
+ zen --config my-config.json # Uses config file
874
+ ```
875
+
876
+ 3. **Default Instances** (Lowest Priority)
877
+ ```bash
878
+ zen # Uses built-in default commands
879
+ ```
880
+
881
+ ## Other Features
882
+
883
+ ### Parallel Execution Control
884
+ ```bash
885
+ # Control startup delay between instances
886
+ zen --startup-delay 30.0 # seconds between launches
887
+
888
+ # Limit console output
889
+ zen --max-console-lines 10
890
+ zen --max-line-length 200
891
+ ```
892
+
893
+ ### Output Formats
894
+ ```bash
895
+ # JSON output
896
+ zen --output-format json
897
+
898
+ # Stream JSON (default)
899
+ zen --output-format stream-json
900
+ ```
901
+
902
+ ### Quiet Mode
903
+ ```bash
904
+ # Minimal output - only errors and summary
905
+ zen --quiet
906
+ ```
907
+
908
+ ### Status Reporting
909
+ ```bash
910
+ # Change status report interval
911
+ zen --status-report-interval 30 # Every 30 seconds
912
+ ```
913
+
914
+ ## Environment Variables
915
+
916
+ ```bash
917
+ # Set default workspace
918
+ export ZEN_WORKSPACE="~/projects"
919
+
920
+ # Set default config
921
+ export ZEN_CONFIG="~/configs/zen-default.json"
922
+
923
+ # Enable debug logging
924
+ export ZEN_DEBUG="true"
925
+ ```
926
+
927
+ ## Troubleshooting
928
+
929
+ ### Command not found
930
+
931
+ #### If using pipx (recommended):
932
+ ```bash
933
+ # Ensure PATH is configured
934
+ pipx ensurepath
935
+
936
+ # Restart terminal, then verify
937
+ zen --version
938
+ ```
939
+
940
+ ### Permission denied
941
+ ```bash
942
+ # Make sure scripts are executable
943
+ chmod +x $(which zen)
944
+ ```
945
+
946
+ ### Module not found
947
+ ```bash
948
+ # Reinstall with dependencies
949
+ pip install --force-reinstall netra-zen
950
+ ```
951
+
952
+ ## Getting Help
953
+
954
+ ```bash
955
+ # Show help
956
+ zen --help
957
+
958
+ # Inspect specific command
959
+ zen --inspect-command /analyze
960
+
961
+ # Visit documentation
962
+ # https://github.com/netra-systems/zen
963
+ ```
964
+
965
+ ### Known Issues
966
+
967
+ **Token Budget Accuracy:**
968
+ - **Problem**: Budget calculations may not exactly match actual API billing
969
+ - **Cause**: Estimates based on local token counting vs. server-side billing
970
+ - **Workaround**: Use conservative budget limits and monitor actual usage through provider dashboards
971
+
972
+ **Configuration File Validation:**
973
+ - **Problem**: Limited validation of JSON configuration files
974
+ - **Impact**: Invalid configurations may cause runtime errors
975
+ - **Workaround**: Use `--dry-run` to validate configurations before execution
976
+
977
+ **Resource Cleanup:**
978
+ - **Problem**: Interrupted executions may leave background processes running
979
+ - **Workaround**: Monitor system processes and manually terminate if necessary
980
+ - **Planned Fix**: Improved signal handling and cleanup in future versions
981
+
982
+ ## Example Configurations
983
+
984
+ See the included example files:
985
+ - `minimal_config.json` - Basic setup
986
+ - `config_example.json` - Standard configuration
987
+ - `netra_apex_tool_example.json` - Advanced integration
988
+
989
+ ## Support
990
+
991
+ - GitHub Issues: https://github.com/netra-systems/zen/issues
992
+ - Documentation: https://github.com/netra-systems/zen/wiki