netra-zen 1.0.9__tar.gz → 1.0.10__tar.gz
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.
- {netra_zen-1.0.9/netra_zen.egg-info → netra_zen-1.0.10}/PKG-INFO +971 -971
- {netra_zen-1.0.9 → netra_zen-1.0.10}/agent_interface/__init__.py +25 -25
- {netra_zen-1.0.9 → netra_zen-1.0.10}/agent_interface/base_agent.py +350 -350
- {netra_zen-1.0.9 → netra_zen-1.0.10}/config_example.json +11 -11
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/CACHE_TOKENS_GUIDE.md +398 -398
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/Cost_allocation.md +372 -372
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/DOLLAR_BUDGET_USAGE_EXAMPLES.md +137 -137
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/EXAMPLES.md +139 -139
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/MODEL_COLUMN_GUIDE.md +159 -159
- {netra_zen-1.0.9 → netra_zen-1.0.10/netra_zen.egg-info}/PKG-INFO +971 -971
- {netra_zen-1.0.9 → netra_zen-1.0.10}/prebuilt_commands_example.json +29 -29
- {netra_zen-1.0.9 → netra_zen-1.0.10}/pyproject.toml +1 -1
- {netra_zen-1.0.9 → netra_zen-1.0.10}/requirements-dev.txt +11 -11
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/bump_version.py +137 -137
- {netra_zen-1.0.9 → netra_zen-1.0.10}/setup.cfg +4 -4
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/__init__.py +5 -5
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_agent_interface.py +389 -389
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_cli_extensions.py +365 -365
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_cli_integration.py +328 -328
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_direct_command_execution.py +475 -475
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_dollar_budget_enhancement.py +279 -279
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_permission_fix_windows.py +262 -262
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_pricing_engine.py +373 -373
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_runner.py +118 -118
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_workspace_detection.py +55 -55
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_zen_commands.py +437 -437
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_zen_integration.py +497 -497
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_zen_metrics.py +465 -465
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_zen_unit.py +692 -692
- {netra_zen-1.0.9 → netra_zen-1.0.10}/token_budget/budget_manager.py +199 -199
- {netra_zen-1.0.9 → netra_zen-1.0.10}/token_budget/models.py +73 -73
- {netra_zen-1.0.9 → netra_zen-1.0.10}/token_budget/visualization.py +21 -21
- {netra_zen-1.0.9 → netra_zen-1.0.10}/token_transparency/__init__.py +19 -19
- {netra_zen-1.0.9 → netra_zen-1.0.10}/token_transparency/claude_pricing_engine.py +326 -326
- netra_zen-1.0.10/zen/telemetry/embedded_credentials.py +26 -0
- netra_zen-1.0.9/zen/telemetry/embedded_credentials.py +0 -59
- {netra_zen-1.0.9 → netra_zen-1.0.10}/LICENSE.md +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/MANIFEST.in +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/README.md +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/apex_integration_test_plan.md +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/docs/zen_agent_cli_parallel_plan.md +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/netra_zen.egg-info/SOURCES.txt +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/netra_zen.egg-info/dependency_links.txt +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/netra_zen.egg-info/entry_points.txt +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/netra_zen.egg-info/requires.txt +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/netra_zen.egg-info/top_level.txt +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/requirements.txt +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/__init__.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/__main__.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/agent_cli.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/agent_logs.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/demo_log_collection.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/embed_release_credentials.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/scripts/verify_log_transmission.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/setup.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_agent_logs.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/tests/test_apex_integration.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/token_budget/__init__.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/zen/__init__.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/zen/__main__.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/zen/telemetry/__init__.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/zen/telemetry/manager.py +0 -0
- {netra_zen-1.0.9 → netra_zen-1.0.10}/zen_orchestrator.py +0 -0
@@ -1,971 +1,971 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: netra-zen
|
3
|
-
Version: 1.0.
|
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
|
-

|
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
|
-

|
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.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
|
+

|
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
|
+

|
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
|