@samboyd/bep-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2026 BEP
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="./img/banner-dark.png">
4
+ <source media="(prefers-color-scheme: light)" srcset="./img/banner-light.png">
5
+ <img alt="Project Banner" src="./img/banner-light.png">
6
+ </picture>
7
+ </p>
8
+
9
+ # BEP: a guardrail for AI coding agents (Claude Code first)
10
+ *Agents speed up execution. BEP makes sure you don’t accelerate in the wrong direction.*
11
+
12
+ > “When code is cheap, you’re forced to make more product bets, more often. The limiting factor becomes selecting the right thing to build and validating it quickly, not implementing it.”
13
+
14
+ BEP prevents “Feature A → B → C” before A is validated by turning “build whatever” into **budgeted bets**:
15
+ - a time cap (hours / calendar days),
16
+ - a validation target (what would prove this matters),
17
+ - a fallback (what you do if validation fails).
18
+
19
+ Rabbit-hole protection for feature work: BEP is the moment where you decide, *do we validate, or do we keep building?*
20
+
21
+ ## How it works (3 lines)
22
+ 1. **Define a bet** (`bep new`) with a cap + validation target.
23
+ 2. **Track time** manually (`bep start`/`bep stop`) or automatically via Claude Code hooks (`bep init --install-hooks`).
24
+ 3. **Use the guardrail**: `bep status` shows when you’re nearing/at cap; Claude hooks can hard-stop new prompts when you’re at cap.
25
+
26
+ <p align="center">
27
+ <picture>
28
+ <source media="(prefers-color-scheme: dark)" srcset="./img/diagram-dark.png">
29
+ <source media="(prefers-color-scheme: light)" srcset="./img/diagram-light.png">
30
+ <img alt="FSM Diagram" src="./img/diagram-light.png">
31
+ </picture>
32
+ </p>
33
+
34
+ ## Supported coding agents
35
+ - **Claude Code** (only supported agent right now) via hooks: `bep init --install-hooks --agent claude-code`.
36
+ - Planned (not supported yet): Codex, Cursor, OpenCode, and other agent runners.
37
+
38
+ ## Supported analytics platforms
39
+ Validation checks run via a provider configured in `.bep.providers.json` (or by manual entry).
40
+
41
+ - **Mixpanel** (`mixpanel`) — see `docs/providers/mixpanel.md`.
42
+ - **Manual entry** (`manual`) — you type the observed value during `bep check`.
43
+
44
+ ## Quick start (Claude Code)
45
+
46
+ ### 1) Install BEP
47
+ ```bash
48
+ npx @samboyd/bep-cli@latest --help
49
+ ```
50
+
51
+ ### 2) Initialize in your repo
52
+ ```bash
53
+ bep init
54
+ ```
55
+ This creates repo-local state under `bets/`:
56
+ ```text
57
+ bets/
58
+ <id>.md
59
+ _state.json
60
+ _logs/
61
+ _evidence/
62
+ ```
63
+ It also creates `.bep.providers.json` (provider config) and (if this is a Git repo) adds `.bep.providers.json` to `.gitignore`.
64
+
65
+ During `init`, BEP will ask if you want to install Claude Code hooks. If you say yes, it writes commands into `.claude/settings.json` for these hook events:
66
+ `UserPromptSubmit`, `PostToolUse`, `PostToolUseFailure`, `SessionEnd`.
67
+
68
+ Non-interactive install:
69
+ ```bash
70
+ # Requires a `.claude/` directory in this repo (or a parent directory)
71
+ bep init --install-hooks --agent claude-code
72
+ ```
73
+
74
+ ### 3) Create a bet
75
+ ```bash
76
+ bep new landing-page-cta
77
+ ```
78
+
79
+ ### 4) Use Claude Code (automatic time tracking)
80
+ Once hooks are installed, Claude Code will call BEP on hook events. BEP will try to attribute work to a bet and (when confident) automatically `start`/`stop`/`switch` so time is tracked without you babysitting timers.
81
+
82
+ Practical pattern: tell Claude which bet it is working on (use the bet id in your prompt), then build until the guardrail warns/blocks.
83
+
84
+ ### 5) Check the guardrail
85
+ ```bash
86
+ bep status
87
+ ```
88
+
89
+ Manual override (if you want it):
90
+ ```bash
91
+ bep start landing-page-cta
92
+ bep stop landing-page-cta
93
+ ```
94
+
95
+ ---
96
+
97
+ ## Why AI coding agent users use BEP
98
+
99
+ AI coding agents are extremely good at *building*. The failure mode is spending hours/tokens producing “finished” features before you’ve validated the underlying assumption.
100
+
101
+ BEP gives you three guardrails:
102
+ - **Time caps**: stop after N hours (or calendar days) instead of “just one more change”.
103
+ - **Validation targets**: force a measurable check before expanding scope.
104
+ - **Fallbacks**: when validation fails, you have a default next move (kill, narrow, pivot, extend).
105
+
106
+ Stop agents from turning uncertainty into sunk cost.
107
+
108
+ ---
109
+
110
+ ## Claude Code mode (hooks that can stop runaway prompts)
111
+
112
+ ### What BEP installs
113
+ `bep init --install-hooks --agent claude-code` writes hook commands into `.claude/settings.json` that call:
114
+ ```text
115
+ bep hook claude-code user-prompt-submit
116
+ bep hook claude-code post-tool-use
117
+ bep hook claude-code post-tool-use-failure
118
+ bep hook claude-code session-end
119
+ ```
120
+
121
+ ### What the guardrail actually does
122
+ On `user-prompt-submit`, BEP may respond with JSON like:
123
+ ```json
124
+ {"continue": false, "stopReason": "Bet 'landing-page-cta' is at cap ..."}
125
+ ```
126
+ That is the “kill switch” moment: Claude is about to keep going, BEP says “stop and validate (or change the bet).”
127
+
128
+ You can sanity-check the hook command locally:
129
+ ```bash
130
+ echo '{"session_id":"demo","prompt":"Implement more changes","cwd":"/repo"}' \
131
+ | bep hook claude-code user-prompt-submit
132
+ ```
133
+
134
+ Notes:
135
+ - Hook events are logged under `bets/_logs/` (for example: `bets/_logs/agent-sessions.jsonl`, `bets/_logs/agent-attribution.jsonl`, `bets/_logs/agent-blocks.jsonl`).
136
+ - If BEP can’t confidently attribute work to a bet, it logs uncertainty and stays non-blocking.
137
+
138
+ ---
139
+
140
+ ## A realistic workflow (day in the life)
141
+ 1. `bep new pricing-page` (set cap, validation, fallback).
142
+ 2. `bep start pricing-page`.
143
+ 3. Paste the “agent contract” (next section) into Claude Code.
144
+ 4. Let Claude implement until BEP warns you via `bep status` or blocks new prompts via hooks.
145
+ 5. Run the validation step; capture evidence with `bep check pricing-page`.
146
+ 6. If validation fails: do the fallback instead of polishing the feature.
147
+
148
+ ---
149
+
150
+ ## Using BEP as an agent contract (paste into Claude)
151
+
152
+ Use this as a system-style rule for Claude Code when working on a bet:
153
+ - Implement only until you hit the time cap (or BEP blocks prompts).
154
+ - If you’re blocked or nearing cap, propose the *smallest validation step* that would change the decision.
155
+ - If validation can’t be reached cheaply, propose the bet’s fallback (kill, narrow, pivot, extend) and stop building.
156
+
157
+ ---
158
+
159
+ ## What BEP is (and isn’t)
160
+ - BEP is a repo-native guardrail for decisions under uncertainty.
161
+ - BEP isn’t a PM suite, an OKR system, or a time-tracking app.
162
+
163
+ ---
164
+
165
+ ## CLI surface (current)
166
+ Use `npx @samboyd/bep-cli@latest ...` if you have not installed it globally.
167
+
168
+ ```text
169
+ bep init [options]
170
+ bep new [id...]
171
+ bep start <id>
172
+ bep stop <id>
173
+ bep status
174
+ bep check <id> [--force]
175
+ bep hook <agent> <event>
176
+ ```
177
+
178
+ `bep init` options:
179
+ - `--install-hooks`
180
+ - `--no-install-hooks`
181
+ - `--agent <agent>` (currently: `claude-code`)
182
+
183
+ ---
184
+
185
+ ## Experimental status (v0.1.0)
186
+ This project is experimental. Expect breaking changes before `v1.0.0`.
187
+
188
+ Safe to try:
189
+ - BEP only adds repo-local files/config under `bets/` and `.bep.providers.json`, plus optional hook config in `.claude/settings.json` if you choose hook install.
190
+ - To remove it, delete `bets/`, delete `.bep.providers.json`, and remove the `.bep.providers.json` entry from `.gitignore` if BEP added it.
191
+
192
+ ---
193
+
194
+ ## More docs
195
+ - `README.md` (full project overview)
196
+ - `docs/agents/claude-code-hooks-integration.md` (hook integration notes; currently a stub)
197
+ - `docs/providers/mixpanel.md` (Mixpanel validation provider)