opencode-skills-collection 3.0.28 → 3.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,269 @@
1
+ ---
2
+ name: mathguard
3
+ description: "Math-heavy escalation for n >= 10^6 — Bloom, HyperLogLog, Count-Min, MinHash/LSH, FFT, JL projection, sweep line. Use when classical O(n log n) is the floor and approximate or math wins."
4
+ risk: safe
5
+ source: community
6
+ source_repo: morsechimwai/lemmaly
7
+ source_type: community
8
+ date_added: "2026-05-26"
9
+ author: morsechimwai
10
+ tags: [algorithms, probabilistic-data-structures, approximate-algorithms, bloom-filter, hyperloglog, fft, performance]
11
+ tools: [claude-code, antigravity, cursor, gemini-cli, codex-cli]
12
+ license: "Apache-2.0"
13
+ license_source: "https://github.com/morsechimwai/lemmaly/blob/main/LICENSE"
14
+ ---
15
+
16
+ # mathguard — Math-Heavy Optimization for AI Code
17
+
18
+ `lemmaly` makes you pick the right classical algorithm. `mathguard` kicks in when the classical algorithm is already optimal but **mathematics gives a better bound** — usually by accepting bounded approximation, exploiting structure, or moving to a smarter algebraic space.
19
+
20
+ The model knows these techniques. It almost never proposes them spontaneously. mathguard fixes that.
21
+
22
+ **Violating the letter of these rules is violating the spirit of the skill.** A Bloom filter where the caller assumed exact answers is a production incident, not an optimization.
23
+
24
+ ## When to Use This Skill
25
+
26
+ Use **mathguard** when:
27
+
28
+ - Working with large-scale data (`n ≥ 10⁶`): similarity search, deduplication, top-K / heavy-hitters, streaming analytics, cardinality estimation, embeddings, recommender systems.
29
+ - Doing signal/image processing, polynomial or big-integer arithmetic, convolution, graph distance, computational geometry, randomized algorithms.
30
+ - The classical O(n log n) is already the floor and you need an asymptotic win (Bloom filter, HyperLogLog, Count-Min Sketch, MinHash/LSH, FFT/NTT, Johnson-Lindenstrauss projection, sweep line, kd-tree/BVH, fast exponentiation, monoid parallel reduction, amortized potential method).
31
+ - Loaded *after* `lemmaly` has confirmed the classical answer is not enough.
32
+
33
+ Do **not** use mathguard when:
34
+ - The caller needs exact answers (auth, billing, dedup-for-correctness, primary keys).
35
+ - `n` is small (n < 10⁴) and the path is not hot.
36
+ - The bottleneck is I/O, not CPU/memory.
37
+
38
+ ## The Iron Law
39
+
40
+ ```text
41
+ NO APPROXIMATE STRUCTURE WITHOUT WRITTEN ε/δ AND EXPLICIT CALLER ACCEPTANCE
42
+ ```
43
+
44
+ Probabilistic data structures (Bloom, HyperLogLog, Count-Min, MinHash/LSH, t-digest), randomized projections (JL), and lossy transforms (floating FFT) all change the answer's meaning. Before proposing one:
45
+
46
+ 1. Write the error parameter the caller will see (false-positive rate, relative error, distortion bound).
47
+ 2. Identify the caller and state, in one sentence, that they tolerate this kind of wrong answer.
48
+ 3. If you cannot identify the caller, or they need exact (auth checks, billing, dedup keys, deduplication for correctness, anything that flows into a primary key), DO NOT propose the approximate structure. Keep classical, or escalate to a sharded/streaming exact design.
49
+
50
+ This rule has saved more incidents than any other in this skill. Do not soften it.
51
+
52
+ ## Non-negotiable rules
53
+
54
+ 1. **Declare exact vs approximate up front.** Before suggesting a math-level technique, state:
55
+ - `mode: exact` or `mode: approximate`
56
+ - If approximate: the error parameter (ε, δ, false-positive rate) and a sentence on whether the caller can tolerate it.
57
+ - If the caller needs exact and there is no exact win, say so and stop — do not silently degrade to approximate.
58
+
59
+ 2. **Cite the technique by name.** Never describe a probabilistic or numerical trick in vague terms. Name it: `Bloom filter`, `HyperLogLog`, `Count-Min Sketch`, `MinHash + LSH`, `Johnson–Lindenstrauss projection`, `FFT`, `NTT`, `fast exponentiation`, `Karatsuba`, `Strassen`, `sweep line`, `kd-tree`, `BVH`, `union-find with path compression`, `Floyd's cycle detection`, `Boyer-Moore majority`, `reservoir sampling`, `Knuth shuffle`, `Aho-Corasick`, `suffix automaton`, `segment tree with lazy propagation`, `Fenwick tree`, `monoid scan / parallel prefix`. A named technique is auditable; "a smart approximation" is not.
60
+
61
+ 3. **State the trade you are making.** Every math-level optimization buys something at a cost. In one line:
62
+ - Buys: `space`, `time`, `wall-clock`, `parallelism`.
63
+ - Costs: `accuracy ε=?`, `code complexity`, `dependency`, `non-determinism`, `numerical stability`.
64
+ - If the cost is invisible to the caller, write "callers see no change".
65
+
66
+ 4. **Justify the asymptotic win.** Do not propose a math technique without a one-line bound argument:
67
+ - "HyperLogLog: count uniques in O(log log n) bits at standard error 1.04/√m."
68
+ - "FFT: polynomial multiplication O(n log n) vs schoolbook O(n²)."
69
+ - "JL projection: preserves pairwise distances within (1±ε) using O(log n / ε²) dimensions."
70
+ - "Sweep line: rectangle overlap from O(n²) pair checks to O(n log n) events."
71
+ No bound, no proposal.
72
+
73
+ 5. **Forbid math cargo-culting.** Do not introduce these techniques when:
74
+ - n is small enough that a linear scan finishes in microseconds (n < ~10⁴ unless it is a hot path).
75
+ - The problem is I/O-bound — the math win disappears behind network/disk.
76
+ - Exact answers are required and no exact technique exists.
77
+ - The team will not maintain it (write that down: "team familiarity: ?").
78
+
79
+ ## The pre-proposal protocol
80
+
81
+ Before suggesting a math-level technique, your message must contain — in this order:
82
+
83
+ 1. **The classical floor** — what is the best non-mathy algorithm and its Big-O? ("Hash join is O(n+m); we're already there.")
84
+ 2. **Why classical is not enough** — n too large, space blows up, real-time deadline, etc.
85
+ 3. **The math technique** — named (rule 2).
86
+ 4. **Exact or approximate** — with ε if approximate (rule 1).
87
+ 5. **The new bound** — with one-line derivation (rule 4).
88
+ 6. **The trade** — buys/costs (rule 3).
89
+ 7. **When NOT to use this** — at least one disqualifier.
90
+ 8. **The code or pseudocode.**
91
+
92
+ If any of 1–7 is missing, do not propose the technique.
93
+
94
+ ## Playbook — math technique → problem → win → caveat
95
+
96
+ ### Sketches and probabilistic structures (massive data, approximate)
97
+
98
+ | Problem | Classical | Math technique | Win | Caveat |
99
+ |---|---|---|---|---|
100
+ | Membership: "have I seen this key?" at scale | `Set<id>`, O(n) space | **Bloom filter** | O(n) bits at chosen ε false-positive | False positives only; cannot remove (use Cuckoo if needed) |
101
+ | Count distinct values in a stream | `Set` to count, O(unique) space | **HyperLogLog** | O(log log n) bits, ~1% relative error | Approximate; cannot list elements |
102
+ | Top-K / heavy hitters in a stream | full counter, O(unique) space | **Count-Min Sketch** + heap | O(log(1/δ)·1/ε) space | Overestimates; choose ε,δ deliberately |
103
+ | Document / set similarity at scale | full Jaccard, O(n·m) | **MinHash + LSH** | Sub-linear ANN query | Tunes recall vs precision; param search |
104
+ | k-NN in high-dim vectors | brute O(n·d) | **JL projection → HNSW / IVF** | O(log n) per query, (1±ε) distortion | Index build cost; recall < 1 |
105
+ | Reservoir of size k from a stream of unknown length | buffer all, O(n) space | **Reservoir sampling** | O(k) space, uniform sample | Single-pass only |
106
+ | Find majority element | counter map | **Boyer-Moore majority vote** | O(1) space, O(n) time | Requires majority exists; verify pass |
107
+ | Quantiles in a stream | sort, O(n log n) | **t-digest / GK** | O(1/ε) space, ε-accurate quantiles | Approximate |
108
+
109
+ ### Fast arithmetic / transforms (numeric and combinatorial)
110
+
111
+ | Problem | Classical | Math technique | Win | Caveat |
112
+ |---|---|---|---|---|
113
+ | Multiply two polynomials / big integers | O(n²) | **FFT / NTT / Karatsuba** | O(n log n) | Floating FFT loses precision — use NTT for integers |
114
+ | Convolution of two signals | O(n·m) | **FFT-based convolution** | O((n+m) log(n+m)) | Numerical noise at very small magnitudes |
115
+ | `pow(a, b) mod p`, b large | O(b) multiplications | **Fast exponentiation (square-and-multiply)** | O(log b) | Watch for overflow inside; use modular arithmetic |
116
+ | GCD of large integers | repeated subtraction | **Euclidean algorithm** | O(log min) | Standard; AI sometimes still writes the subtraction loop |
117
+ | Matrix multiplication, n large | O(n³) | **Strassen** (then Coppersmith-Winograd family) | O(n^2.81) | High constant; only wins for very large dense |
118
+ | Solving Ax=b for sparse A | O(n³) dense | **Conjugate gradient / sparse LU** | O(nnz · iterations) | Numerical conditioning matters |
119
+ | Modular inverse | brute force | **Extended Euclidean** or **Fermat** when p prime | O(log p) | p must be prime for Fermat |
120
+
121
+ ### Dimensionality reduction and linear algebra
122
+
123
+ | Problem | Classical | Math technique | Win | Caveat |
124
+ |---|---|---|---|---|
125
+ | Similarity in d-dim, d large | O(n·d) brute | **JL projection** to k = O(log n / ε²) | O(n·k) at (1±ε) distortion | Random; verify on validation set |
126
+ | Recommender from rating matrix | iterate full matrix | **Truncated SVD / matrix factorization** | O(k·(n+m)) for rank-k | Choose k; refresh strategy |
127
+ | Document-term similarity | TF-IDF O(n·m) | **LSA via SVD** | rank-k approximation | Latent dims are not interpretable |
128
+ | PCA on n samples in d dims | O(n·d²) | **Randomized SVD** | O(n·d·k) for rank-k | Randomized; set oversampling |
129
+
130
+ ### Geometry (spatial queries)
131
+
132
+ | Problem | Classical | Math technique | Win | Caveat |
133
+ |---|---|---|---|---|
134
+ | Range / nearest-neighbor in 2D-3D | O(n) per query | **kd-tree / R-tree / BVH** | O(log n) per query | Degrades in high d; use ANN instead |
135
+ | Rectangle / interval overlap pairs | O(n²) pair check | **Sweep line + active set (BBST)** | O((n+k) log n) | k = output size; segment tree variant exists |
136
+ | Polygon point-in-polygon at scale | O(n·v) | **BSP / monotone decomposition / R-tree** | O(log v) per query after build | Build cost |
137
+ | Convex hull of n points | O(n²) gift wrap | **Graham scan / Andrew's monotone chain** | O(n log n) | Numerical robustness for collinear |
138
+ | Closest pair of points | O(n²) | **Divide and conquer** | O(n log n) | Carefully merge across the strip |
139
+
140
+ ### Graph and algebraic tricks
141
+
142
+ | Problem | Classical | Math technique | Win | Caveat |
143
+ |---|---|---|---|---|
144
+ | Connected components under merges | recompute BFS each merge | **Union-Find with path compression + rank** | α(n) ≈ O(1) per op amortized | Inverse Ackermann is effectively constant |
145
+ | Range sum / update on array | O(n) per query | **Fenwick tree** | O(log n) per op | Inclusive ranges; off-by-one risk |
146
+ | Range query with monoid (sum/min/max/gcd) | O(n) per query | **Segment tree (with lazy if range updates)** | O(log n) | More code than Fenwick; more general |
147
+ | LCA in a tree, many queries | O(n) per query | **Binary lifting** or **Euler tour + RMQ** | O(log n) or O(1) per query | Preprocessing cost |
148
+ | Shortest path on DAG | Dijkstra | **Topo sort + relax** | O(V+E) | Only works on DAG |
149
+ | Detect cycle in linked list | hash visited | **Floyd's tortoise and hare** | O(1) space | Same big-O time, dramatic space win |
150
+ | Parallel reduction over n items | sequential fold | **Monoid + parallel scan** | O(n/p + log p) on p cores | Operation must be associative; verify it |
151
+
152
+ ### Amortized and online algorithms
153
+
154
+ | Problem | Classical | Math technique | Win | Caveat |
155
+ |---|---|---|---|---|
156
+ | "Dynamic array push is expensive" | per-op O(n) on resize | **Amortized analysis (doubling)** | O(1) amortized | This is what `ArrayList` / `vec` already do; just defend it |
157
+ | Streaming median | re-sort | **Two heaps (max-heap + min-heap)** | O(log n) per insert | Maintain size invariant |
158
+ | Online interval scheduling | re-sort by deadline | **Greedy with priority queue** | O(log n) per arrival | Specific objective; check problem fit |
159
+ | Sliding-window max | O(n·k) | **Monotonic deque** | O(n) total | Window invariant subtle to maintain |
160
+
161
+ ## Canonical example — counting distinct users
162
+
163
+ **Problem.** Count unique users seen across a 24-hour event stream. ~2B events/day, ~50M unique users. Reported on a dashboard, ±2% is acceptable.
164
+
165
+ ### Without the protocol — silent OOM, or worse, silent billing error
166
+
167
+ ```ts
168
+ // "Just use a Set" — silently OOMs the box at ~50M strings
169
+ const seen = new Set<string>();
170
+ for await (const event of stream) {
171
+ seen.add(event.userId);
172
+ }
173
+ return seen.size; // exact, but the process died at row 41M
174
+ ```
175
+
176
+ Or worse — proposed *with* a HyperLogLog "for performance" but plugged into the billing pipeline, which keys off the result. Billing then sees 49.7M instead of 50.0M users and a fraction never get charged.
177
+
178
+ ### With the protocol — auditable HLL
179
+
180
+ ```ts
181
+ // Classical floor: O(unique) memory for an exact Set. At 50M strings × ~50B each, ~2.5GB.
182
+ // Why classical is not enough: dashboard box has 512MB and refreshes every minute.
183
+ // Technique: HyperLogLog (HLL).
184
+ // Mode: approximate. ε ≈ 1.04/√m. With m=2^14 registers → ~0.8% relative error.
185
+ // Trade: buys O(log log n)-bit space (~12KB); costs ±0.8% on the displayed count.
186
+ // When NOT to use: anything that flows into billing, primary keys, or per-user actions.
187
+ // Caller acceptance: confirmed — dashboard product owner accepts ±2%, written in PR.
188
+
189
+ import { createHLL } from 'hyperloglog-lite';
190
+ const hll = createHLL({ precision: 14 });
191
+ for await (const event of stream) {
192
+ hll.add(event.userId);
193
+ }
194
+ return hll.estimate(); // 49.6M ± 0.4M; dashboard reads ~50M
195
+ ```
196
+
197
+ The first version is not "no HLL" — it is "HLL without writing down ε and who tolerates it." The second is identical in technique but auditable: ε is in the comment, the caller is named, the disqualifier (billing) is explicit.
198
+
199
+ ## Output discipline
200
+
201
+ Code that uses a math-level technique must include:
202
+
203
+ - One comment naming the technique with a doc link or one-line citation.
204
+ - The exact error parameters chosen (ε, δ, bits, dimensions, etc.) and why those values.
205
+ - A measured or asymptotic justification next to the chosen parameters.
206
+ - An exact-mode fallback path, if the caller might need it.
207
+
208
+ ## When to escalate or redirect
209
+
210
+ - The bottleneck is I/O, not CPU/memory → go back to `lemmaly` rule 4; math will not help.
211
+ - You need bit-exact reproducibility → avoid floating FFT, randomized projections, and probabilistic structures.
212
+ - The result is consumed by a downstream system that assumes exact → keep classical or wrap with a validation pass.
213
+ - You need a correctness proof (not just a bound) → load **invariant-guard** after picking the technique.
214
+
215
+ ## Rationalizations to watch for
216
+
217
+ | Excuse | Reality |
218
+ | --- | --- |
219
+ | "A `set` works — I'll flag the memory issue in a comment." | Noticing the problem is not solving it. If memory is the budget, ship the structure that respects it. |
220
+ | "Probabilistic structures sound fancy / academic." | Cloudflare runs Bloom filters in the request path. Redis ships HyperLogLog. These are production-tested, not academic. |
221
+ | "Approximate is risky — I'll do exact and let it OOM later." | Silent OOM at 3am is riskier than a stated 0.81% error. State the ε, pick parameters, ship. |
222
+ | "I'll just shard the set across machines." | Sharding multiplies your infra cost; HLL solves it in 12KB on one box. Ask whether you actually need exact. |
223
+ | "FFT is overkill for this." | True 99% of the time. But state the n. At n ≥ ~64 for polynomial mult, schoolbook is already losing. |
224
+ | "JL projection feels too lossy for embeddings." | At ε = 0.1, JL preserves pairwise distances within 10%. For ANN this is almost always fine — measure recall, do not eyeball. |
225
+
226
+ ## Red flags — STOP
227
+
228
+ - Proposing a probabilistic structure without stating ε and δ.
229
+ - Saying "we can use FFT here" without writing the n at which FFT actually beats schoolbook.
230
+ - Using `JSON.parse(JSON.stringify(...))` to deep-clone when `structuredClone` exists, then claiming it as an optimization.
231
+ - Recommending Strassen on a 100×100 matrix.
232
+ - Switching to approximate output without the caller having agreed to it.
233
+ - Naming a technique you cannot derive the bound for.
234
+ - Math optimization where n is small and not on a hot path.
235
+ - "Should be O(log n) on average" with no average-case argument.
236
+
237
+ ## Verification checklist
238
+
239
+ Before shipping code that uses a math-level technique:
240
+
241
+ - [ ] The technique is named (no "a smart approximation").
242
+ - [ ] If approximate: ε and δ (or the equivalent error parameter) are written in code or in the PR description.
243
+ - [ ] The caller has been identified and their tolerance for that error is stated.
244
+ - [ ] A one-line bound derivation is present (asymptotic or measured).
245
+ - [ ] At least one disqualifier ("when NOT to use this") is documented.
246
+ - [ ] An exact-mode fallback exists, OR a one-line note explains why exact is impossible.
247
+ - [ ] If randomized: the seed strategy is documented (fixed for reproducibility, or stated as non-deterministic).
248
+ - [ ] Downstream consumers that assume exactness (joins on this value, billing, auth, primary keys) have been audited.
249
+
250
+ Cannot check every box? The technique is not ready to ship. Keep classical, or stop and ask.
251
+
252
+ ## Limitations
253
+
254
+ - **Not for exact-required pipelines.** Any system where the result is a primary key, dedup key, billing input, or auth decision is out of scope — keep classical.
255
+ - **Assumes representative inputs.** ε/δ bounds are average-case or high-probability; adversarial inputs can blow past them. State the threat model.
256
+ - **Library quality varies.** Bloom / HLL / MinHash implementations differ in seed strategy, hash function, and memory layout — pick a maintained library and pin the version.
257
+ - **Numerical stability.** Floating FFT, randomized SVD, and JL projection accumulate float error; for combinatorial exactness use NTT or exact integer variants.
258
+ - **Team-familiarity risk.** A technique nobody can debug at 3 a.m. is a liability — write the maintainer note next to the trade-off.
259
+ - **Not a profiler.** mathguard tells you which asymptotic ceiling you can break; it does not measure constant factors. Benchmark before claiming a wall-clock win.
260
+
261
+ ## The thesis, in one line
262
+
263
+ > **When classical algorithms hit their floor, mathematics still has another floor below. mathguard makes the model reach for it instead of accepting the first answer.**
264
+
265
+ ## Related Skills
266
+
267
+ - `lemmaly` — gateway; pick the classical algorithm first before reaching for math.
268
+ - `invariant-guard` — for stating ε-bounds as part of the postcondition of an approximate algorithm.
269
+ - `complexity-cuts` — when baseline code already exists and the bottleneck is CPU/memory, not approximation.
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: sendblue-api
3
+ description: "Send and receive iMessage, SMS, and RCS from application code via the Sendblue HTTP API — text, media, group messages, send styles, reactions, typing indicators, status callbacks, and inbound webhooks."
4
+ category: api-integration
5
+ risk: safe
6
+ source: community
7
+ source_type: official
8
+ date_added: "2026-05-22"
9
+ author: AnthonyFirth
10
+ tags: [sendblue, imessage, sms, rcs, messaging, api, webhooks]
11
+ tools: [claude, cursor, gemini]
12
+ ---
13
+
14
+ # Sendblue API
15
+
16
+ ## Overview
17
+
18
+ Sendblue is a REST API that sends iMessage (blue bubbles), SMS, and RCS from a provisioned phone number. Everything is plain JSON over HTTPS — no SDK is required. The API covers outbound 1:1 and group sends, iMessage effects, reactions, typing indicators, status callbacks, and inbound webhooks.
19
+
20
+ ## When to Use This Skill
21
+
22
+ - Use when writing application code (server, worker, function) that sends Sendblue messages as part of a long-running service.
23
+ - Use when receiving inbound messages via webhooks.
24
+ - Use when you need features the CLI does not expose: send styles, reactions, group messages, typing indicators, status callbacks, media uploads, or the contacts API beyond basic CRUD.
25
+ - Reach for [[sendblue-cli]] instead for shell-context outbound: one-shot scripts, cron jobs, agent hooks, "ping me when X" workflows.
26
+
27
+ ## How It Works
28
+
29
+ ### Step 1: Authenticate
30
+
31
+ ```
32
+ https://api.sendblue.com
33
+ ```
34
+
35
+ Every request needs two headers:
36
+
37
+ ```
38
+ sb-api-key-id: <YOUR_API_KEY_ID>
39
+ sb-api-secret-key: <YOUR_API_SECRET>
40
+ Content-Type: application/json
41
+ ```
42
+
43
+ Keep both values server-side — never ship them to a browser or mobile client.
44
+
45
+ ### Step 2: Send a message
46
+
47
+ ```bash
48
+ curl -X POST https://api.sendblue.com/api/send-message \
49
+ -H "sb-api-key-id: $KEY_ID" \
50
+ -H "sb-api-secret-key: $SECRET" \
51
+ -H 'Content-Type: application/json' \
52
+ -d '{
53
+ "number": "+15551234567",
54
+ "from_number": "+1YOUR_SENDBLUE_NUMBER",
55
+ "content": "Hello from the API!"
56
+ }'
57
+ ```
58
+
59
+ Phone numbers must be E.164. `from_number` must be a line you own — list yours with `GET /api/lines`.
60
+
61
+ ### Step 3: Track delivery
62
+
63
+ The synchronous response includes a `message_handle` (Apple GUID — persist this; you need it for reactions and replies) and a `status` from `REGISTERED`, `PENDING`, `QUEUED`, `ACCEPTED`, `SENT`, `DELIVERED`, `DECLINED`, `ERROR`. Only `DELIVERED` means it landed. Use `status_callback` instead of polling `/api/status`.
64
+
65
+ ### Step 4: Receive inbound
66
+
67
+ Configure webhook URLs in the dashboard or via `POST /api/account/webhooks`. Sendblue POSTs JSON to your endpoint. Respond with 2xx promptly — non-2xx triggers retries and duplicate deliveries. Event types: `receive`, `outbound`, `typing_indicator`, `call_log`, `line_blocked`, `line_assigned`, `contact_created`.
68
+
69
+ ## Core Endpoints
70
+
71
+ | Method | Path | Purpose |
72
+ |--------|------|---------|
73
+ | POST | `/api/send-message` | Send a 1:1 message (text and/or media) |
74
+ | POST | `/api/send-group-message` | Send to multiple recipients |
75
+ | POST | `/api/create-group` | Create a named group thread |
76
+ | POST | `/api/send-reaction` | Send a tapback (love/like/dislike/laugh/emphasize/question) |
77
+ | POST | `/api/send-typing-indicator` | Show "typing…" in the recipient's thread |
78
+ | POST | `/api/mark-read` | Send a read receipt |
79
+ | POST | `/api/upload-file` / `/api/upload-media-object` | Upload media (direct or from URL) |
80
+ | GET | `/api/status` | Poll a message's delivery status |
81
+ | GET | `/api/evaluate-service` | Check whether a number is on iMessage |
82
+ | GET | `/api/v2/messages` / `/api/v2/messages/:id` | Read message history |
83
+ | GET / POST / PUT / DELETE | `/api/v2/contacts[...]` | Manage contacts |
84
+ | GET | `/api/lines` | List your Sendblue phone numbers |
85
+ | POST | `/api/account/webhooks` | CRUD webhook subscriptions |
86
+
87
+ ## Examples
88
+
89
+ ### Example 1: Send with media, effects, and a status callback
90
+
91
+ ```json
92
+ POST /api/send-message
93
+ {
94
+ "number": "+15551234567",
95
+ "from_number": "+1YOUR_SENDBLUE_NUMBER",
96
+ "content": "Optional text",
97
+ "media_url": "https://example.com/img.jpg",
98
+ "send_style": "celebration",
99
+ "status_callback": "https://yourapp.com/sendblue/status"
100
+ }
101
+ ```
102
+
103
+ `content` and/or `media_url` is required. `send_style` is iMessage-only — valid values: `celebration`, `shooting_star`, `fireworks`, `lasers`, `love`, `confetti`, `balloons`, `spotlight`, `echo`, `invisible`, `gentle`, `loud`, `slam`. Ignored on SMS. Text up to 18,996 chars; media up to 100 MB on iMessage, 5 MB on SMS.
104
+
105
+ ### Example 2: Group message
106
+
107
+ ```json
108
+ POST /api/send-group-message
109
+ {
110
+ "numbers": ["+15551234567", "+15557654321"],
111
+ "from_number": "+1YOUR_SENDBLUE_NUMBER",
112
+ "content": "Hey team"
113
+ }
114
+ ```
115
+
116
+ The response returns a `group_id` — persist it to send follow-ups into the same thread instead of creating a new one each time.
117
+
118
+ ### Example 3: React to a message
119
+
120
+ ```json
121
+ POST /api/send-reaction
122
+ {
123
+ "from_number": "+1YOUR_SENDBLUE_NUMBER",
124
+ "message_handle": "<message_handle from prior send>",
125
+ "reaction": "love"
126
+ }
127
+ ```
128
+
129
+ Reactions only work on iMessage and need the original message's `message_handle`. Valid values: `love`, `like`, `dislike`, `laugh`, `emphasize`, `question`.
130
+
131
+ ### Example 4: Inbound webhook payload (`receive`)
132
+
133
+ ```json
134
+ {
135
+ "accountEmail": "you@example.com",
136
+ "content": "Reply text",
137
+ "media_url": "https://...",
138
+ "is_outbound": false,
139
+ "number": "+15551234567",
140
+ "from_number": "+1YOUR_SENDBLUE_NUMBER",
141
+ "service": "iMessage",
142
+ "group_id": "...",
143
+ "date_sent": "2024-01-01T12:00:00Z"
144
+ }
145
+ ```
146
+
147
+ Status callback payloads (`outbound`) mirror the send-message response and update as the message moves through `SENT` → `DELIVERED` (or `ERROR`).
148
+
149
+ ## Best Practices
150
+
151
+ - ✅ **Persist `message_handle` on every send.** You need it for reactions, replies, and correlating status callbacks.
152
+ - ✅ **Use `status_callback` over polling.** It's lower-cost and more accurate than `GET /api/status`.
153
+ - ✅ **Return 2xx fast from your webhook**, then process async. Non-2xx triggers duplicate deliveries.
154
+ - ✅ **Check service with `/api/evaluate-service`** before relying on iMessage-only features for a recipient.
155
+ - ✅ **Rehost inbound media on receipt** — media URLs expire in ~30 days.
156
+ - ❌ **Don't ship `sb-api-key-id` / `sb-api-secret-key` to a client.** They are server-side credentials.
157
+ - ❌ **Don't treat a 200 on `/api/send-message` as delivery.** It only means "accepted".
158
+
159
+ ## Limitations
160
+
161
+ - Synchronous send responses only report acceptance, not delivery. Final state arrives via `status_callback` or `GET /api/status`.
162
+ - `send_style` silently no-ops on SMS (green-bubble recipients).
163
+ - Inbound media URLs expire in ~30 days.
164
+ - Per-line rate limits apply; bursting many sends from one number can trip Apple's spam heuristics — pace them or split across lines.
165
+ - Reactions and effects are iMessage-only.
166
+
167
+ ## Security & Safety Notes
168
+
169
+ - Keep `sb-api-key-id` and `sb-api-secret-key` server-side. They are not safe in browser, mobile, or CI logs.
170
+ - Webhook endpoints should be on HTTPS and idempotent — same `message_handle` may arrive more than once.
171
+ - Sensitive data in message content is visible in lock-screen previews on the recipient's device. Don't embed secrets, tokens, or full PII — link to an authenticated dashboard or shortened payload instead.
172
+ - Rotate API keys from the Sendblue dashboard if either value is exposed; the old pair is invalidated on rotation.
173
+
174
+ ## Common Pitfalls
175
+
176
+ - **E.164 only.** `5551234567` or `(555) 123-4567` will fail — always send `+15551234567`.
177
+ - **`from_number` must be one of your lines.** A spoofed or unprovisioned number returns an error.
178
+ - **`send_style` silently no-ops on SMS.** If the recipient is green-bubble, effects don't render — check service first with `/api/evaluate-service` if it matters.
179
+ - **Store `message_handle`.** You need it for reactions, replies, and correlating status callbacks back to your records.
180
+ - **Media URLs expire in ~30 days.** If you need durable media from inbound webhooks, download and re-host on receipt.
181
+ - **Status is async.** A 200 on `/api/send-message` means accepted, not delivered. Use `status_callback` rather than blocking on the synchronous response.
182
+ - **Webhook retries on non-2xx.** Return 200 even when you've decided to ignore the event; otherwise expect duplicate deliveries.
183
+ - **Rate limits apply per line.** Bursting many sends from one number trips Apple's spam heuristics — pace them or split across lines.
184
+
185
+ ## Related Skills
186
+
187
+ - `@sendblue-cli` — Shell wrapper for shell-context outbound (scripts, cron, agent hooks). Use it when you don't need a full HTTP integration.
188
+ - `@sendblue-notify` — Patterns and copy rules for outbound "text me when X is done" notifications layered on top of the API or CLI.
189
+
190
+ ## Links
191
+
192
+ - Full reference: <https://docs.sendblue.com/>
193
+ - Sendblue: <https://sendblue.com>
194
+ - Useful undocumented-here features: carousels (`/api/send-carousel`), FaceTime/contact-card sharing, advanced webhook filtering, contacts API beyond basic CRUD — see the docs site.
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: sendblue-cli
3
+ description: "Send iMessage and SMS from the shell via the @sendblue/cli npm package — outbound sends, contact management, and account setup with no API client or webhook server required."
4
+ category: api-integration
5
+ risk: safe
6
+ source: community
7
+ source_repo: sendblue-api/sendblue-cli
8
+ source_type: official
9
+ date_added: "2026-05-22"
10
+ author: AnthonyFirth
11
+ tags: [sendblue, imessage, sms, cli, messaging, notifications]
12
+ tools: [claude, cursor, gemini]
13
+ license: "MIT"
14
+ license_source: "https://github.com/sendblue-api/sendblue-cli/blob/main/LICENSE"
15
+ ---
16
+
17
+ # Sendblue CLI
18
+
19
+ ## Overview
20
+
21
+ `@sendblue/cli` is a Node CLI that creates a Sendblue account, provisions an iMessage-enabled number, and sends messages. It is the fastest way to text from a shell, script, or Claude Code hook — no API client, no webhook server, no credentials in env vars. Credentials live at `~/.sendblue/credentials.json` (mode `600`) and Node.js 18+ is required.
22
+
23
+ ## When to Use This Skill
24
+
25
+ - Use when the user wants to text a phone number from a script, shell, hook, or agent turn (e.g. "text me when X finishes", "ping my phone", "notify on completion").
26
+ - Use when the user mentions `sendblue` as a CLI/binary or asks to set up the `@sendblue/cli` package.
27
+ - Prefer this skill over [[sendblue-api]] when the work happens in a shell context, one-shot script, cron job, or agent hook.
28
+ - Reach for [[sendblue-api]] instead when writing application code that integrates Sendblue, receiving inbound webhooks, or needing features the CLI does not expose (send styles, reactions, group messages, status callbacks, media uploads).
29
+
30
+ ## How It Works
31
+
32
+ ### Step 1: Install
33
+
34
+ ```bash
35
+ npm install -g @sendblue/cli # global, exposes `sendblue`
36
+ # or one-shot:
37
+ npx @sendblue/cli <command>
38
+ ```
39
+
40
+ ### Step 2: Set up an account
41
+
42
+ `sendblue setup` runs interactively by default. For CI/scripts, run it in two phases — the first call sends an 8-digit verification code by email, the second consumes it.
43
+
44
+ ```bash
45
+ sendblue setup --email you@example.com # sends code
46
+ sendblue setup --email you@example.com --code 12345678 \
47
+ --company my-co --contact +15551234567 # completes setup
48
+ ```
49
+
50
+ | Flag | Notes |
51
+ |---|---|
52
+ | `--email` | Email address |
53
+ | `--code` | 8-digit verification code (from the email) |
54
+ | `--company` | Lowercase, hyphens/underscores, 3–64 chars |
55
+ | `--contact` | First contact, E.164 |
56
+
57
+ ### Step 3: Send messages
58
+
59
+ ```bash
60
+ sendblue send +15551234567 'Hello from Sendblue!'
61
+ sendblue messages --inbound --limit 20
62
+ ```
63
+
64
+ Phone numbers must be E.164 (`+` + country code + digits, no spaces or dashes).
65
+
66
+ ### Step 4: Manage contacts and plan
67
+
68
+ On the free plan, **a contact must text your Sendblue number once before outbound sends to that contact will work**. After `sendblue setup ... --contact +15551234567`, have that contact send any text to the printed Sendblue number, then run `sendblue contacts` to confirm verification.
69
+
70
+ ## Command Reference
71
+
72
+ | Command | Purpose |
73
+ |---|---|
74
+ | `sendblue setup` | Create account, verify email, set company name, add first contact |
75
+ | `sendblue login` | Log in to an existing account |
76
+ | `sendblue send <number> <message>` | Send an iMessage |
77
+ | `sendblue messages [--inbound\|--outbound] [-n <number>] [-l <count>]` | List recent messages |
78
+ | `sendblue add-contact <number>` | Register a contact |
79
+ | `sendblue contacts` | List contacts and their verification status |
80
+ | `sendblue status` | Account/plan info |
81
+ | `sendblue whoami` | Show current credentials and verify validity |
82
+
83
+ ## Examples
84
+
85
+ ### Example 1: Notify when a long task finishes
86
+
87
+ ```bash
88
+ long_running_thing && sendblue send +15551234567 "✅ done: $(date)"
89
+ ```
90
+
91
+ ### Example 2: Read recent inbound for a specific contact
92
+
93
+ ```bash
94
+ sendblue messages -n +15551234567 --inbound --limit 50
95
+ ```
96
+
97
+ ### Example 3: Verify creds are good before a batch send
98
+
99
+ ```bash
100
+ sendblue whoami || sendblue login
101
+ ```
102
+
103
+ ### Example 4: Wire to a Claude Code `Stop` hook
104
+
105
+ To text yourself at the end of every agent turn, register a `Stop` hook in `settings.json` that shells out to `sendblue send`. Defer the actual hook wiring to [[update-config]] and the trigger logic to [[sendblue-notify]] — this skill only owns the CLI invocation.
106
+
107
+ ## Best Practices
108
+
109
+ - ✅ **Use E.164 numbers everywhere.** `+15551234567`, never `5551234567` or `(555) 123-4567`.
110
+ - ✅ **Run `sendblue whoami` before unattended batches** to fail fast on stale or missing creds.
111
+ - ✅ **Re-run `setup` as the same OS user** that owns `~/.sendblue/credentials.json`.
112
+ - ❌ **Don't `sudo`** — it writes creds to root's home and the next non-sudo run won't see them.
113
+ - ❌ **Don't embed creds in env vars** when the CLI already reads them from the per-user credentials file.
114
+
115
+ ## Limitations
116
+
117
+ - Outbound-first: there is no built-in webhook server for inbound. Use [[sendblue-api]] webhooks for full inbound handling.
118
+ - The CLI does not expose send styles/effects, reactions, group messages, status callbacks, media uploads, or the contacts API beyond basic CRUD. Reach for the HTTP API for those.
119
+ - Free-plan accounts require recipient verification before outbound sends succeed.
120
+
121
+ ## Security & Safety Notes
122
+
123
+ - Credentials are written to `~/.sendblue/credentials.json` with mode `600`. Treat that file like an API key — do not commit it, do not copy it across machines without the same posture.
124
+ - Run the CLI as the OS user that owns the credentials file. `sudo` writes a separate copy under root's home and silently desyncs.
125
+ - Outbound messages to phone numbers are not free of consequence — wire `sendblue send` into hooks or loops only after gating on duration or success conditions to avoid spamming the recipient.
126
+ - Verification codes arrive by email; treat the address you registered with as a recovery factor for the account.
127
+
128
+ ## Common Pitfalls
129
+
130
+ - **E.164 only.** `5551234567` or `(555) 123-4567` will fail — always `+15551234567`.
131
+ - **Free-plan unverified contacts.** Outbound to a contact that hasn't texted in first returns an error — have them text your Sendblue number once, then confirm with `sendblue contacts`.
132
+ - **Two-step setup in non-interactive mode.** `--email` alone only sends the code; you must run a second invocation with `--code` and the rest of the flags to finish.
133
+ - **Credentials are per-user.** `~/.sendblue/credentials.json` is owner-only (`600`). Don't `sudo` and pollute root's home — re-running as the same user that ran `setup` is what works.
134
+
135
+ ## Related Skills
136
+
137
+ - `@sendblue-api` — HTTP/JSON alternative for application code, webhooks, and features the CLI does not expose.
138
+ - `@sendblue-notify` — Patterns and copy rules for "text me when X is done" workflows that sit on top of this CLI.
139
+ - `@update-config` — Wires `sendblue send` into Claude Code hooks (`Stop`, `Notification`) without owning the message logic.
140
+
141
+ ## Links
142
+
143
+ - README & full flag reference: <https://github.com/sendblue-api/sendblue-cli>
144
+ - Sendblue: <https://sendblue.com>
145
+ - API docs (deeper protocol details): <https://docs.sendblue.com>