@chainpatrol/sdk 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1659 @@
1
+ 'use strict';
2
+
3
+ // src/skill/content.ts
4
+ function buildSkillContent(version) {
5
+ return `---
6
+ name: chainpatrol
7
+ version: ${version}
8
+ description: |
9
+ ChainPatrol CLI assistant. Helps use the chainpatrol CLI tool: login via device
10
+ code flow, check auth status, list detection configs, list reports (including
11
+ customer-reported ones), run CLI commands, and run an organization
12
+ healthcheck across the detection / reviewing / blocklisting / takedown
13
+ pipeline.
14
+ Use when: "chainpatrol cli", "login to chainpatrol", "check detection configs",
15
+ "am I logged in", "list configs", "use the cli", "list reports",
16
+ "customer reports", "reports reported by customer", "find detection gaps",
17
+ "org healthcheck", "organization health check", "audit my org",
18
+ "what's wrong with org", "review org setup", "list orgs", "list organizations",
19
+ "get org", "get organization", "show org details", "org by slug",
20
+ "fetch org details", "org info",
21
+ "orgs with takedowns off", "automation off across orgs",
22
+ "which customers have X enabled", "service toggles by org",
23
+ "obligatory admin approval", "obligatory organization admin approval",
24
+ "obligatory approval", "admin approval enabled", "admin approval orgs",
25
+ "requires customer review", "requires admin approval",
26
+ "orgs that require admin approval", "orgs requiring approval",
27
+ "which orgs require approval for twitter", "approval scope",
28
+ "admin approval asset types", "approval per asset type",
29
+ "pending approval", "pending approvals", "pending service approval",
30
+ "orgs with pending approval", "pending wallet blocking approval",
31
+ "pending takedown approval", "awaiting approval", "waiting for approval",
32
+ "is protection active approval", "wallet blocking approval",
33
+ "who needs to approve wallet blocking", "service change request",
34
+ "track orgs with pending approval", "orgs awaiting sign-off",
35
+ "is this URL blocked", "is this domain blocked", "is this address blocked",
36
+ "check this asset", "asset check", "lookup asset status",
37
+ "what is ARCHIVE_ORG", "what does PAGE mean", "list asset types",
38
+ "supported asset types", "asset type mapping", "asset type enum",
39
+ "what asset types are there", "human readable asset type",
40
+ "how many takedowns", "takedowns in the last", "threats taken down",
41
+ "across all clients", "across all customers", "across all orgs",
42
+ "across all brands", "company-wide", "total takedowns", "total threats",
43
+ "total reports", "average takedowns", "average threats", "average per day",
44
+ "average per customer", "average per org", "rollup across customers",
45
+ "sum across orgs", "sum across customers",
46
+ "trends in org", "search for trends", "trend search", "look for trends",
47
+ "any trends", "trending threats", "spike in asset type",
48
+ "spike in threat volume", "coordinated attack", "spike check",
49
+ "anything unusual", "anything new for", "what's new for",
50
+ "employee being targeted", "spike on a sub-brand", "spike on a brand",
51
+ "sub-brand spike",
52
+ "list brands", "brands for org", "list sub-brands", "employee brands",
53
+ "individual brands", "brand list", "all brands in org".
54
+ allowed-tools:
55
+ - Bash
56
+ - Read
57
+ - Grep
58
+ - Glob
59
+ ---
60
+
61
+ # ChainPatrol CLI Skill
62
+
63
+ You are a ChainPatrol CLI assistant. Help the user interact with the ChainPatrol
64
+ platform using the CLI tool.
65
+
66
+ ## Running the CLI
67
+
68
+ IMPORTANT: Claude Code's sandbox shell often has a minimal PATH
69
+ (\`/usr/bin:/bin:/usr/sbin:/sbin\`) that may not include the directory where
70
+ \`chainpatrol\` is installed, so bare \`chainpatrol\` calls may fail with
71
+ "command not found". Always invoke the CLI by its full path.
72
+
73
+ The install location depends on the environment:
74
+
75
+ - **Local installs** typically land at \`/usr/local/bin/chainpatrol\` (when
76
+ installed globally via \`npm install -g @chainpatrol/cli\`).
77
+ - **Cloud / sandboxed environments** (e.g. Claude Code on the web, Cursor
78
+ Cloud) often install Node into \`/opt\` and the binary ends up under a
79
+ Node-version-specific path like \`/opt/node22/bin/chainpatrol\`. Variants
80
+ such as \`/opt/node20/bin/chainpatrol\` or \`/opt/node21/bin/chainpatrol\`
81
+ are also possible depending on which Node version is active.
82
+
83
+ To find the binary, try (in order):
84
+
85
+ \`\`\`bash
86
+ command -v chainpatrol \\
87
+ || ls /usr/local/bin/chainpatrol /opt/node*/bin/chainpatrol 2>/dev/null \\
88
+ | head -n 1
89
+ \`\`\`
90
+
91
+ Then use that full path for every subsequent command, e.g.:
92
+
93
+ \`\`\`bash
94
+ /opt/node22/bin/chainpatrol <command> [options]
95
+ # or
96
+ /usr/local/bin/chainpatrol <command> [options]
97
+ \`\`\`
98
+
99
+ All examples below use the short name \`chainpatrol\` for readability, but you
100
+ MUST substitute the full resolved path in your Bash commands.
101
+
102
+ ## Available Commands
103
+
104
+ ### \`login\` \u2014 Authenticate with ChainPatrol
105
+
106
+ Uses the OAuth Device Code flow (RFC 8628):
107
+ 1. CLI requests a device code from the server
108
+ 2. User is shown a code and a URL to visit
109
+ 3. User authorizes in the browser
110
+ 4. CLI polls for the token
111
+
112
+ \`\`\`bash
113
+ chainpatrol login
114
+ \`\`\`
115
+
116
+ JSON mode (for automation):
117
+ \`\`\`bash
118
+ chainpatrol --json login
119
+ \`\`\`
120
+
121
+ #### Running \`login\` from an agent (headless / non-TTY)
122
+
123
+ The login flow blocks for up to 30 minutes while polling for the user to
124
+ authorize in their browser. If you (the agent) run it as a foreground
125
+ command and wait for it to exit before reading output, you will appear
126
+ stuck \u2014 the verification URL will never be shown because the process is
127
+ still polling.
128
+
129
+ **Always run \`login\` in the background and stream its output**, then
130
+ surface the verification URL to the user as soon as it appears:
131
+
132
+ \`\`\`bash
133
+ # 1. Kick off login in the background (do NOT wait for it to exit)
134
+ chainpatrol --json login > /tmp/cp-login.out 2>&1 &
135
+
136
+ # 2. Wait briefly for the first line, which contains the URL
137
+ for _ in 1 2 3 4 5 6 7 8 9 10; do
138
+ test -s /tmp/cp-login.out && break
139
+ sleep 1
140
+ done
141
+ cat /tmp/cp-login.out
142
+ \`\`\`
143
+
144
+ The first line emitted is JSON describing the device code, e.g.:
145
+
146
+ \`\`\`json
147
+ {"action":"open_url","user_code":"ABCD-1234","verification_uri":"https://app.chainpatrol.io/auth/verify-device","verification_uri_complete":"https://app.chainpatrol.io/auth/verify-device?user_code=ABCD-1234","expires_in":1800,"headless":true}
148
+ \`\`\`
149
+
150
+ Show the user the \`verification_uri_complete\` link (or
151
+ \`verification_uri\` + \`user_code\` as a fallback) and explain that the
152
+ CLI will pick up the token automatically once they authorize. Then keep
153
+ the background process running and tail it for the final
154
+ \`{"status":"success",...}\` or \`{"error":...}\` line.
155
+
156
+ CLI v0.3.3+ also auto-detects non-TTY stdout and prints the URL as plain
157
+ text immediately when you run \`chainpatrol login\` without \`--json\`,
158
+ so the same background+tail pattern works without \`--json\`. Prefer
159
+ \`--json\` so the output is structured and machine-parseable.
160
+
161
+ ### \`logout\` \u2014 Clear stored credentials
162
+
163
+ \`\`\`bash
164
+ chainpatrol logout
165
+ \`\`\`
166
+
167
+ ### \`asset check\` \u2014 Check one or many assets against the blocklist
168
+
169
+ Look up a URL, domain, or crypto address and return its aggregated status
170
+ (\`BLOCKED\`, \`ALLOWED\`, or \`UNKNOWN\`) plus a per-source breakdown
171
+ (ChainPatrol + external feeds like eth-phishing-detect, phishfort, seal,
172
+ polkadot-phishing). Works whether you're authenticated via device-code
173
+ login or via a \`CHAINPATROL_API_KEY\` env var.
174
+
175
+ Single asset:
176
+
177
+ \`\`\`bash
178
+ chainpatrol asset check https://phish.example
179
+ chainpatrol asset check 0xabc123...
180
+ \`\`\`
181
+
182
+ #### Bulk checks (preferred for >1 asset)
183
+
184
+ Pass multiple assets in a single invocation \u2014 the CLI runs them in
185
+ parallel (concurrency 10) and returns one row per asset. **Do this
186
+ instead of looping the CLI in a shell \`for\` loop**: one process, one
187
+ auth handshake, parallel HTTP. Use either positional args or repeated
188
+ \`--asset\`:
189
+
190
+ \`\`\`bash
191
+ # positional form
192
+ chainpatrol asset check a.example b.example c.example
193
+
194
+ # repeated --asset (handy when content has spaces or special chars)
195
+ chainpatrol asset check --asset a.example --asset b.example
196
+
197
+ # from a file of one-asset-per-line (use xargs to splat into one call)
198
+ xargs -a domains.txt chainpatrol asset check
199
+ \`\`\`
200
+
201
+ JSON mode is the agent-friendly default \u2014 single-asset JSON keeps the
202
+ flat \`{ content, status, source, reason?, sources[], watchStatus? }\`
203
+ shape; multi-asset JSON returns \`{ results: [...], summary: { checked,
204
+ blocked, allowed, unknown, errored } }\`:
205
+
206
+ \`\`\`bash
207
+ chainpatrol --json asset check https://phish.example
208
+ chainpatrol --json asset check a.example b.example c.example
209
+ \`\`\`
210
+
211
+ Markdown / CSV are also available for sharing in docs / chat:
212
+
213
+ \`\`\`bash
214
+ chainpatrol asset check phish.example --output markdown
215
+ chainpatrol asset check a.example b.example --output csv
216
+ \`\`\`
217
+
218
+ If any individual lookup fails, the CLI still prints results for the
219
+ successful ones, then exits non-zero so failures aren't silently
220
+ swallowed.
221
+
222
+ ### \`asset types\` \u2014 List every supported asset type and what it means
223
+
224
+ When a user asks "what is \`ARCHIVE_ORG\`?", "what does \`PAGE\` mean?",
225
+ or "what asset types does ChainPatrol support?" \u2014 don't guess. Run:
226
+
227
+ \`\`\`bash
228
+ chainpatrol asset types
229
+ chainpatrol --json asset types
230
+ \`\`\`
231
+
232
+ The mapping is bundled with the CLI (no API or auth required), so this
233
+ is safe to run anywhere. Each row is \`{ type, label, description }\`:
234
+ \`type\` is the canonical enum value used by every \`--asset-type\` flag
235
+ (\`asset list\`, \`threats list\`, \`takedowns list\`, \`detections list\`,
236
+ \`reports list\`, \`orgs assets list\`); \`label\` is the human-friendly
237
+ display name (\`ARCHIVE_ORG\` \u2192 \`Archive.org\`, \`PAGE\` \u2192 \`Page\`,
238
+ \`FIVE_HUNDRED_PX\` \u2192 \`500px\`); \`description\` is a one-line note for
239
+ unobvious entries.
240
+
241
+ Use this whenever you need to translate between enum and display name,
242
+ validate that a type the user mentioned is real, or enumerate options
243
+ before constructing a filter.
244
+
245
+ ### \`configs list\` \u2014 List detection configurations
246
+
247
+ Requires authentication and an organization slug.
248
+
249
+ \`\`\`bash
250
+ chainpatrol configs list --org <slug>
251
+ \`\`\`
252
+
253
+ JSON mode:
254
+ \`\`\`bash
255
+ chainpatrol --json configs list --org <slug>
256
+ \`\`\`
257
+
258
+ The \`--org\` flag is saved for future commands. Once set, you can omit it:
259
+ \`\`\`bash
260
+ chainpatrol configs list
261
+ \`\`\`
262
+
263
+ ### \`reports list\` \u2014 List recent reports for an organization
264
+
265
+ Returns the most recent reports submitted for an organization. Each report
266
+ includes a \`reportedByCustomer\` boolean indicating whether the report was
267
+ submitted by a customer of ChainPatrol (e.g. via API key, Slack/Telegram bot,
268
+ or another external integration) rather than by ChainPatrol's automated
269
+ detections or staff reviewers.
270
+
271
+ \`\`\`bash
272
+ chainpatrol reports list --org <slug>
273
+ \`\`\`
274
+
275
+ Common flags:
276
+ - \`--limit <n>\` page size (1-20)
277
+ - \`--cursor <id>\` pagination cursor (use \`nextCursor\` from a previous response)
278
+ - \`--status <s>\` filter by report status (e.g. \`TODO\`, \`IN_PROGRESS\`, \`DONE\`)
279
+ - \`--search <q>\` search query across title/description/asset content
280
+ - \`--reported-by-customer\` only show reports submitted by a customer
281
+ - \`--no-reported-by-customer\` only show reports NOT submitted by a customer
282
+ (i.e. found by ChainPatrol's automation or staff)
283
+
284
+ JSON mode is recommended when you want to analyze the data programmatically:
285
+ \`\`\`bash
286
+ chainpatrol --json reports list --org <slug> --reported-by-customer
287
+ \`\`\`
288
+
289
+ The response includes \`totalCount\`: the number of reports matching the same
290
+ filters as the query, independent of \`--limit\`/\`--cursor\`. Use it to:
291
+ - Report a denominator when sampling (e.g. "sampled 200 of ~4,235").
292
+ - Decide up front whether to page through everything or narrow filters first \u2014
293
+ if \`totalCount\` is huge, add more filters instead of paginating blindly.
294
+ - Drive a progress indicator while paginating with \`nextCursor\`.
295
+
296
+ \`totalCount\` honors every list filter (\`--status\`, \`--reported-by-customer\` /
297
+ \`--no-reported-by-customer\`, \`--exclude-automation\`, \`--review-status\` /
298
+ \`--only-rejected\`, \`--asset-type\`, brand, \`--country-code\`, \`--from\`/\`--to\`,
299
+ \`--updated-from\`/\`--updated-to\`, \`--search\`, \`--reporter-query\`), so changing
300
+ filters changes the count. \`reports\` (the returned page) is capped by
301
+ \`--limit\` (max 20); \`totalCount\` is not.
302
+
303
+ #### Use case: finding gaps in ChainPatrol detection
304
+
305
+ Customer-reported reports (\`reportedByCustomer=true\`) are a valuable signal
306
+ for finding gaps in ChainPatrol's automated detections and staff triage: each
307
+ one is a threat the customer found before ChainPatrol's own systems did. When
308
+ the user asks something like:
309
+
310
+ - "show me the threats our customers are reporting"
311
+ - "what is X's customer reporting?"
312
+ - "where are we missing detections for org Y?"
313
+ - "summarize recent reports submitted by customers"
314
+
315
+ \u2026use \`chainpatrol --json reports list --org <slug> --reported-by-customer\`
316
+ to fetch them, then highlight patterns (asset types, domains, common
317
+ keywords, recurring brands) so the user can:
318
+ 1. Spot detection coverage gaps to fix in the org's detection configs.
319
+ 2. Improve staff triage runbooks for recurring scams.
320
+ 3. Work directly with the customer to close the loop and prevent future
321
+ misses.
322
+
323
+ You can also compare with the non-customer set using
324
+ \`--no-reported-by-customer\` to gauge detection coverage on the same time
325
+ window.
326
+
327
+ ### \`detections healthcheck\` \u2014 Validate enabled detection configs produce recent results
328
+
329
+ Server-side check. The CLI calls the ChainPatrol API; the server fetches each
330
+ enabled detection config for the org, counts results produced in the lookback
331
+ window, and FAILs configs that fall under \`--min-results\` (or whose run
332
+ errored when \`--run\` is set).
333
+
334
+ \`\`\`bash
335
+ chainpatrol --json detections healthcheck --org <slug>
336
+ \`\`\`
337
+
338
+ Flags:
339
+ - \`--source <key>\` only validate one source (e.g. \`twitter_search\`)
340
+ - \`--min-results <n>\` minimum results required in the window to pass
341
+ - \`--lookback-hours <n>\` size of the lookback window
342
+ - \`--run\` ask the server to run each config first, then validate the fresh output
343
+ - \`--include-disabled\` also validate disabled configs
344
+
345
+ What this command covers:
346
+ - Configs that have gone silent (recentResultCount below threshold)
347
+ - Configs that error when run (runOk=false) when \`--run\` is set
348
+
349
+ What it does NOT cover:
350
+ - Reviewing backlog / SLA breaches \u2192 use \`queues snapshot\`
351
+ - Takedown ToDo / In Progress / Cancelled volumes \u2192 use \`queues snapshot\`
352
+ - Spikes or drops in detection volume over time \u2192 use \`metrics breakdown\`
353
+ - Customer-reported gaps \u2192 use \`reports list --reported-by-customer\`
354
+ - Google Safe Browsing submission errors (not yet exposed in CLI)
355
+
356
+ Use it as the first signal in the Detection part of an org healthcheck, then
357
+ fall back to the manual checks in the HealthCheck Guide below for everything
358
+ else.
359
+
360
+ > Prefer the newer \`healthchecks\` namespace below. \`detections healthcheck\`
361
+ > is the original single-purpose command; the \`healthchecks\` namespace is
362
+ > the canonical place to discover and run every check we expose.
363
+
364
+ ### \`healthchecks list | run\` \u2014 Run uniform org healthchecks via the public API
365
+
366
+ The \`healthchecks\` namespace is the canonical way to run the named checks
367
+ from the Organization HealthCheck Guide below. Each implemented endpoint
368
+ returns the same uniform shape \u2014 \`{ id, ok, severity, observed, threshold,
369
+ findings, suggestedAction }\` \u2014 so the CLI / agent can render every check the
370
+ same way regardless of category.
371
+
372
+ \`\`\`bash
373
+ # Discover every check the platform exposes today, including planned checks
374
+ # that are not yet implemented on the backend.
375
+ chainpatrol --json healthchecks list
376
+
377
+ # Run a single named check.
378
+ chainpatrol --json healthchecks run reviewing.backlog --org <slug>
379
+
380
+ # Run every implemented check in parallel and aggregate the results.
381
+ chainpatrol --json healthchecks run --all --org <slug>
382
+ \`\`\`
383
+
384
+ Each implemented check has a stable id of the form \`category.name\`. Implemented
385
+ ids today: \`detections.silent-configs\`, \`reviewing.backlog\`,
386
+ \`reviewing.old-proposals\`, \`reviewing.watchlist-backlog\`,
387
+ \`reviewing.watchlist-old\`, \`takedowns.todo-volume\`,
388
+ \`takedowns.in-progress-volume\`, \`takedowns.stale-in-progress\`,
389
+ \`takedowns.cancelled-count\`, \`takedowns.automation-off\`,
390
+ \`assets.dead-asset-spike\`.
391
+
392
+ ### Pending proposals: "Needs Review" vs "Watchlisted"
393
+
394
+ PENDING proposals split into two operationally distinct buckets, and we
395
+ grade them with separate checks:
396
+
397
+ - **Needs Review** \u2014 pending proposals the reviewing UI shows by default
398
+ (\`excludeWatchlisted=true\`): assets that are NOT on a watchlist, OR
399
+ reports submitted by a customer (those stay visible even when the asset
400
+ is watchlisted). This is the actionable queue reviewers work from, so
401
+ pile-ups and old items here are high-priority signals (\`fail\` severity
402
+ is reachable).
403
+ - **Watchlisted** \u2014 pending proposals on watchlisted assets (excluding
404
+ customer-reported reports). The reviewing UI hides these by default
405
+ because watchlisting is the act of intentionally deferring an asset.
406
+ Pile-ups and aged items here are worth surfacing as cleanup work, but
407
+ severity is **capped at warn** so they never block on the same SLA as
408
+ Needs Review. When reporting findings, treat these as lower-priority.
409
+
410
+ Each healthcheck result includes an \`appUrl\` field (string or null) that
411
+ deep-links to the relevant filtered admin page in the web app \u2014 e.g. the
412
+ takedowns page filtered to IN_PROGRESS for \`takedowns.stale-in-progress\`,
413
+ or the review page filtered to oldest pending for \`reviewing.old-proposals\`.
414
+ **When reporting a non-OK healthcheck to the user, always surface the
415
+ \`appUrl\` so they can jump straight to the right view.** Some checks
416
+ (\`detections.silent-configs\`, \`assets.dead-asset-spike\`) emit \`null\`
417
+ because no filterable list page exists for that signal yet.
418
+
419
+ Implemented checks today:
420
+
421
+ - **detections.silent-configs** \u2014 equivalent to \`detections healthcheck\`,
422
+ exposed under the uniform shape.
423
+ - **reviewing.backlog** \u2014 counts Needs Review pending proposals and grades
424
+ severity against per-org thresholds (default warn=50, fail=100).
425
+ - **reviewing.old-proposals** \u2014 counts Needs Review proposals older than
426
+ the warn / fail age thresholds (default 7 / 14 days) and lists the
427
+ oldest offenders.
428
+ - **reviewing.watchlist-backlog** \u2014 counts watchlisted pending proposals
429
+ (default warn=200). Severity capped at warn.
430
+ - **reviewing.watchlist-old** \u2014 counts watchlisted pending proposals older
431
+ than the warn-age threshold (default 30 days) and lists the oldest.
432
+ Severity capped at warn.
433
+ - **takedowns.todo-volume** \u2014 counts takedowns in TODO (default warn=50,
434
+ fail=100). Pile-ups here usually mean an automation gap on a new threat
435
+ surface, or manual-filing capacity issues.
436
+ - **takedowns.in-progress-volume** \u2014 counts takedowns currently IN_PROGRESS
437
+ regardless of age (default warn=30, fail=75). Complements
438
+ \`stale-in-progress\` \u2014 a high count signals vendor-side or
439
+ submission-format problems even before items go stale.
440
+ - **takedowns.stale-in-progress** \u2014 counts takedowns sitting in IN_PROGRESS
441
+ past the staleness threshold (default 7 days) and lists the oldest.
442
+ - **takedowns.cancelled-count** \u2014 counts CANCELLED transitions from the
443
+ TakedownEvent log over a rolling window (default 7d, warn=3, fail=10).
444
+ Cancellations should be rare; a spike usually means a proposal-funnel
445
+ quality problem or misuse of the CANCELLED status.
446
+ - **takedowns.automation-off** \u2014 flags orgs with takedown service enabled
447
+ but \`isAutomatedTakedownsActive\` off for too long (default warn=30d,
448
+ fail=60d). Skipped for orgs with takedown service entirely disabled.
449
+ - **assets.dead-asset-spike** \u2014 compares DEAD-detection events in the
450
+ current window against the prior baseline rate; warns on a multiplier
451
+ exceeding the threshold (default 24h vs 7d, \xD72 warn / \xD74 fail) once the
452
+ current count clears the \`minSpikeCount\` floor. Catches liveness-checker
453
+ regressions after platform changes.
454
+
455
+ The following checks are listed by \`healthchecks list\` (\`implemented: false\`)
456
+ but **not yet implemented on the backend** \u2014 when the agent surfaces them in
457
+ a healthcheck report, mark them explicitly as "manual check, no API yet":
458
+
459
+ - **detections.coverage-gaps** \u2014 blocked assets vs. enabled-source correlation.
460
+ Still requires manual reasoning with \`configs list\` + \`reports list\`.
461
+ - **detections.spike** / **detections.drop** \u2014 require server-side baseline
462
+ modeling. Use \`metrics breakdown --by day\` as an interim signal.
463
+ - **reviewing.auto-approval-spike** \u2014 needs distinguishing automation vs.
464
+ human approvers in the review history. Use \`metrics breakdown\` as a proxy.
465
+ - **blocklisting.gsb-cancelled-rate** \u2014 Google Safe Browsing submission state
466
+ is not yet exposed in the public API.
467
+ - **assets.dead-but-alive** / **assets.alive-but-marked-dead** \u2014 require live
468
+ HTTP probes against asset URLs, which is not a synchronous-healthcheck
469
+ shape. Until a dedicated probe command exists, sample a handful manually
470
+ from \`assets list --status DEAD\` (or ALIVE) and verify in a browser. Notify
471
+ ChainPatrol engineering if the liveness checker looks miscalibrated.
472
+
473
+ When the user asks to "run a healthcheck on org X", the canonical command is:
474
+
475
+ \`\`\`bash
476
+ chainpatrol --json healthchecks run --all --org X
477
+ \`\`\`
478
+
479
+ This iterates the implemented entries in \`healthchecks list\`, runs them in
480
+ parallel, and aggregates the uniform results. Combine with the manual checks
481
+ in the HealthCheck Guide below for everything still marked
482
+ \`implemented: false\`.
483
+
484
+ ### \`queues snapshot\` \u2014 Operations review/takedown queue snapshot
485
+
486
+ Server-side aggregation of the operations review queue (pending proposals,
487
+ SLA breaches, age buckets) and the takedown queue (open, in-progress, stale).
488
+
489
+ \`\`\`bash
490
+ chainpatrol --json queues snapshot --org <slug>
491
+ \`\`\`
492
+
493
+ Useful for the **Reviewing** and **Takedowns** sections of the HealthCheck
494
+ Guide. Key signals in the response:
495
+ - \`reviewQueue.totalPendingProposals\` and \`reviewQueue.distinctReports\` \u2014
496
+ backlog size
497
+ - \`reviewQueue.slaBuckets.breached\` \u2014 SLA breaches (treat any breach as a
498
+ finding)
499
+ - \`reviewQueue.ageBuckets.gte168h\` \u2014 proposals older than 7 days (anything
500
+ >14 days from the manual guide should always be in here)
501
+ - \`takedownQueue.totalOpen\` and \`takedownQueue.staleInProgress\` \u2014 open
502
+ and stuck takedowns
503
+
504
+ Use \`--all\` to snapshot every org you have access to instead of a single slug.
505
+
506
+ ### \`orgs list\` \u2014 List organizations with subscription status, service toggles, and admin-approval scope
507
+
508
+ Returns every organization the caller can see, with each org's
509
+ subscription status (\`PROSPECT\`, \`TRIAL\`, \`ACTIVE\`, \`INTEGRATION\`),
510
+ which services are active, and the per-org "Obligatory Organization
511
+ Admin Approval" toggle (with its asset-type scope). Use it to answer
512
+ questions like "which customers have takedowns enabled but automation
513
+ off?", "which prospects don't have detection turned on yet?", or "which
514
+ orgs require admin approval before adding Twitter assets to the
515
+ blocklist?" \u2014 filters compose with AND and are applied server-side, so
516
+ one call returns the final list.
517
+
518
+ \`\`\`bash
519
+ chainpatrol --json orgs list \\
520
+ --subscription-status ACTIVE \\
521
+ --service-active takedowns \\
522
+ --service-manual takedowns
523
+ \`\`\`
524
+
525
+ #### Per-service response shape \u2014 \`automated\` is takedowns-only
526
+
527
+ Every service exposes an \`active\` boolean. **Only \`takedowns\`
528
+ additionally exposes \`automated\`** \u2014 that is the one service where the
529
+ manual-vs-automated distinction changes real platform behavior (whether
530
+ ChainPatrol files the takedown on its own, or queues it for a human to
531
+ file). \`reporting\`, \`reviewing\`, and \`protection\` have backing
532
+ \`isAutomated*Active\` columns in the database, but those flags have no
533
+ operational effect today, so the API deliberately omits them from both
534
+ the response and the \`services\` filter \u2014 surfacing them would invite
535
+ misleading filters like "reporting.automated=true" that don't mean
536
+ anything. \`detection\` and \`darkWebMonitoring\` have always been
537
+ single-flag services.
538
+
539
+ #### Obligatory Organization Admin Approval
540
+
541
+ Each org also has a separate "Obligatory Organization Admin Approval"
542
+ toggle (\`Organization.requiresCustomerReview\` in the schema, surfaced
543
+ on the Services settings page in the app) that gates customer-side
544
+ review of proposals ChainPatrol staff have already approved before
545
+ they're added to the blocklist. It is NOT one of the operational
546
+ services above \u2014 it is an org-policy toggle with its own per-asset-type
547
+ scope.
548
+
549
+ Each org's response includes:
550
+
551
+ \`\`\`json
552
+ {
553
+ "obligatoryAdminApproval": {
554
+ "active": true,
555
+ "assetTypes": ["TWITTER", "URL"]
556
+ }
557
+ }
558
+ \`\`\`
559
+
560
+ - \`active=true\` + empty \`assetTypes\` means approval applies to
561
+ **all** asset types \u2014 the org has not narrowed the scope.
562
+ - \`active=true\` + a non-empty \`assetTypes\` list means approval is
563
+ required only for those asset types.
564
+ - \`active=false\` means no approval is required; \`assetTypes\` is
565
+ always empty in that case.
566
+
567
+ So per-org JSON looks like:
568
+
569
+ \`\`\`json
570
+ {
571
+ "services": {
572
+ "reporting": { "active": true },
573
+ "reviewing": { "active": true },
574
+ "protection": { "active": false },
575
+ "takedowns": { "active": true, "automated": false },
576
+ "detection": { "active": true },
577
+ "darkWebMonitoring": { "active": false }
578
+ },
579
+ "obligatoryAdminApproval": { "active": true, "assetTypes": ["TWITTER"] },
580
+ "pendingServiceApprovals": [
581
+ {
582
+ "service": "protection",
583
+ "automated": false,
584
+ "serviceType": "isProtectionActive",
585
+ "serviceName": "Wallet Blocking",
586
+ "requestedAt": "2026-05-30T18:04:11.000Z"
587
+ }
588
+ ]
589
+ }
590
+ \`\`\`
591
+
592
+ #### Pending service approvals (Wallet Blocking / Takedowns)
593
+
594
+ Turning on **Wallet Blocking** (\`protection\`, the "is protection active"
595
+ toggle) or **Takedowns** is approval-gated: when a lower-level org member
596
+ tries to enable one, ChainPatrol records a pending request that a higher-up
597
+ at the org \u2014 an org OWNER, or ChainPatrol staff acting as owner \u2014 must
598
+ approve before the service actually turns on. \`pendingServiceApprovals\`
599
+ lists those open, awaiting-sign-off requests per org.
600
+
601
+ This is the answer to "which organizations have a pending approval for
602
+ Wallet blocking or Takedown services?" \u2014 it is NOT the same as "which orgs
603
+ have Wallet Blocking turned off". An org can have \`protection.active=false\`
604
+ with **no** pending approval (nobody has asked) OR **with** a pending
605
+ approval (someone asked and it's waiting on an owner). Only
606
+ \`pendingServiceApprovals\` distinguishes the two.
607
+
608
+ Each entry:
609
+
610
+ - \`service\` \u2014 \`protection\` (Wallet Blocking) or \`takedowns\`, matching the
611
+ \`services\` keys.
612
+ - \`automated\` \u2014 \`true\` when the request is for the automated variant
613
+ (e.g. "Automated Wallet Blocking").
614
+ - \`serviceType\` \u2014 raw enum, e.g. \`isProtectionActive\`.
615
+ - \`serviceName\` \u2014 human label, e.g. \`Wallet Blocking\`.
616
+ - \`requestedAt\` \u2014 when the enable request was submitted (ISO 8601, UTC).
617
+
618
+ An **empty array means nothing is awaiting approval** \u2014 read \`services\` for
619
+ the current on/off state, never infer it from this field.
620
+
621
+ When a user asks about "automated reporting / reviewing / protection",
622
+ explain that the flag exists in the DB but has no operational effect and
623
+ isn't exposed by the public API \u2014 only \`takedowns.automated\` carries a
624
+ real meaning.
625
+
626
+ Filter flags (all optional, all comma-separated lists where noted):
627
+
628
+ - \`--query <text>\` partial name match (substring, case-insensitive)
629
+ - \`--subscription-status <list>\` one or more of \`PROSPECT\`, \`TRIAL\`,
630
+ \`ACTIVE\`, \`INTEGRATION\`. \`INACTIVE\` is intentionally not reachable
631
+ through this filter \u2014 \`orgs list\` only ever returns live customers.
632
+ - \`--service-active <list>\` services that must be active
633
+ - \`--service-inactive <list>\` services that must be inactive
634
+ - \`--service-automated <list>\` services whose automation must be ON.
635
+ **Only \`takedowns\` is accepted** \u2014 the other services don't have a
636
+ meaningful automation toggle. Passing any other service name errors out.
637
+ - \`--service-manual <list>\` services whose automation must be OFF.
638
+ Same restriction \u2014 only \`takedowns\`.
639
+ - \`--obligatory-approval-active\` \u2014 only orgs with admin approval on
640
+ - \`--obligatory-approval-inactive\` \u2014 only orgs with admin approval off
641
+ - \`--obligatory-approval-asset-type <list>\` \u2014 only orgs whose admin
642
+ approval scope covers EVERY listed asset type. The match treats an
643
+ org's empty per-asset-type list as "applies to all asset types", so a
644
+ fully-broad org matches every value passed here. Passing this flag
645
+ implies the feature is on, so it can't be combined with
646
+ \`--obligatory-approval-inactive\`. Use the canonical asset-type enum
647
+ names (\`TWITTER\`, \`URL\`, \`PAGE\`, \u2026); run \`chainpatrol asset types\`
648
+ to see them all.
649
+ - \`--pending-approval-active\` \u2014 only orgs with at least one open
650
+ service-enable approval awaiting a higher-up's sign-off.
651
+ - \`--pending-approval-inactive\` \u2014 only orgs with no pending approvals.
652
+ - \`--pending-approval-service <list>\` \u2014 only orgs with a pending approval
653
+ for one of the listed services. Accepts \`protection\` (Wallet Blocking)
654
+ and/or \`takedowns\` \u2014 those are the only approval-gated services.
655
+ Matches both the manual and automated variant. Passing this flag implies
656
+ a pending approval exists, so it can't be combined with
657
+ \`--pending-approval-inactive\`.
658
+
659
+ Service names: \`reporting\`, \`reviewing\`, \`protection\`, \`takedowns\`,
660
+ \`detection\`, \`darkWebMonitoring\`.
661
+
662
+ Customers see only orgs they're a member of. Staff/superuser sessions see
663
+ every matching org. The response is the same in both cases; visibility is
664
+ enforced server-side.
665
+
666
+ #### Use case: finding which orgs require admin approval for an asset type
667
+
668
+ When a user asks "which orgs require admin approval before blocking
669
+ Twitter assets?", reach straight for the filter \u2014 no client-side
670
+ post-processing needed:
671
+
672
+ \`\`\`bash
673
+ chainpatrol --json orgs list --obligatory-approval-asset-type TWITTER
674
+ \`\`\`
675
+
676
+ To audit just the broad opt-ins ("which orgs require approval for
677
+ everything?"), filter on the toggle and inspect \`assetTypes\` in the
678
+ output \u2014 an empty array means "all":
679
+
680
+ \`\`\`bash
681
+ chainpatrol --json orgs list --obligatory-approval-active \\
682
+ | jq '.organizations[] | select(.obligatoryAdminApproval.assetTypes | length == 0) | .slug'
683
+ \`\`\`
684
+
685
+ #### Use case: tracking orgs with a pending Wallet Blocking / Takedown approval
686
+
687
+ When a user asks "which organizations have a pending approval for Wallet
688
+ blocking or Takedown services?", do NOT reach for \`--service-inactive
689
+ protection\` \u2014 that lists orgs with the service turned OFF, which is a
690
+ different question. Use the pending-approval filter, which surfaces
691
+ staff-initiated enable requests still waiting on a higher-up:
692
+
693
+ \`\`\`bash
694
+ # Every org with a pending Wallet Blocking OR Takedown approval:
695
+ chainpatrol --json orgs list --pending-approval-service protection,takedowns
696
+
697
+ # Just Wallet Blocking:
698
+ chainpatrol --json orgs list --pending-approval-service protection
699
+
700
+ # Any pending approval at all, then read each org's pendingServiceApprovals:
701
+ chainpatrol --json orgs list --pending-approval-active \\
702
+ | jq '.organizations[] | {slug, pending: [.pendingServiceApprovals[].serviceName]}'
703
+ \`\`\`
704
+
705
+ ### \`orgs get\` \u2014 Get a single organization by slug
706
+
707
+ Look up one organization the caller has access to. Returns the same per-org
708
+ shape as a single row from \`orgs list\` \u2014 \`active\` for every service,
709
+ plus \`automated\` on \`takedowns\` only (see the note above on why other
710
+ services don't expose an automation flag), plus \`obligatoryAdminApproval\`
711
+ (\`active\` + \`assetTypes\`) and \`pendingServiceApprovals\` (open Wallet
712
+ Blocking / Takedown enable requests awaiting a higher-up's sign-off).
713
+ Anything you could read from \`orgs list\` you can also read here without
714
+ paging or filtering. Use it when the user names a specific customer ("show
715
+ me acme's setup", "is takedowns automation on for morpho?", "does this org
716
+ require admin approval for Twitter?", "is morpho waiting on a Wallet
717
+ Blocking approval?") and you don't need the rest of the catalogue.
718
+
719
+ \`\`\`bash
720
+ chainpatrol orgs get <slug>
721
+ chainpatrol --json orgs get <slug>
722
+ \`\`\`
723
+
724
+ Permission rules match \`orgs list\`:
725
+
726
+ - Org-scoped API keys: must match the slug \u2014 querying another org returns
727
+ 403.
728
+ - User sessions / user-scoped API keys: need an active OrganizationMembership
729
+ on the slug. Staff/superusers can read any org.
730
+ - Soft-deleted orgs are not returned (404). A 404 also fires for orgs the
731
+ caller would not be authorized to see \u2014 the endpoint deliberately does
732
+ not distinguish "doesn't exist" from "you can't see this" beyond the
733
+ generic 403/404 envelope.
734
+
735
+ Prefer \`orgs get\` over \`orgs list\` + client-side filter whenever the
736
+ caller already knows the slug; it's one round-trip and side-steps the
737
+ list filters entirely.
738
+
739
+ #### Use case: finding service configuration gaps across the customer base
740
+
741
+ When the user asks something like "which customers are paying us but don't
742
+ have takedowns automated yet?" or "any orgs running detection without
743
+ takedowns?", reach for \`orgs list\` \u2014 it's the only command that exposes
744
+ service flags across multiple orgs in one call. Run it in \`--json\` mode
745
+ and summarize patterns by service or by subscription tier.
746
+
747
+ ### \`brands list\` \u2014 List the brands (sub-brands) belonging to an org
748
+
749
+ Returns every brand for the org the caller is authenticated as, both
750
+ parent / product brands (\`type: "ORGANIZATION"\`) and individual /
751
+ employee brands (\`type: "INDIVIDUAL"\`). Soft-deleted brands are excluded.
752
+ The endpoint is org-scoped and inferred from auth \u2014 there's no \`--org\`
753
+ flag \u2014 so org-scoped API keys, user API keys, and user sessions all work
754
+ without extra arguments.
755
+
756
+ \`\`\`bash
757
+ chainpatrol brands list # all brands
758
+ chainpatrol brands list --type INDIVIDUAL # employee / person brands only
759
+ chainpatrol brands list --type ORGANIZATION # product / parent brands only
760
+ chainpatrol --json brands list # machine-readable
761
+ \`\`\`
762
+
763
+ Each entry has \`{ id, slug, name, type, description, brandGroupId, createdAt }\`.
764
+ Use this when you need to:
765
+
766
+ - Distinguish employee vs. product brands ahead of time \u2014 e.g. while
767
+ running a trend search and you want to highlight which spiking
768
+ sub-brands are employees so the user gets a direct heads-up to the
769
+ person involved.
770
+ - Resolve a brand name the user mentions to its \`slug\` for use with
771
+ \`metrics organization --brand-slug <slug>\` or as a \`brandId\` for
772
+ \`takedowns list --brand <id>\`.
773
+ - Audit a customer's setup \u2014 "how many employee brands does this org
774
+ protect?" or "are there brands the org set up but never wired into a
775
+ detection config?"
776
+
777
+ ### \`metrics summary | found | breakdown | organization\` \u2014 Org metrics for spike/drop analysis
778
+
779
+ #### Decision rule \u2014 read this before picking a metrics subcommand
780
+
781
+ When the user asks for a number that **spans more than one customer/org/brand**
782
+ \u2014 phrases like "across all clients", "across all customers", "across all orgs",
783
+ "across all brands", "company-wide", "total takedowns", "total threats",
784
+ "average takedowns per day across customers", "rollup across customers",
785
+ "how many takedowns in the last 7 days?" (no org named) \u2014 the answer is
786
+ **\`chainpatrol metrics organization --all-my-orgs\`** (or \`--slugs\`
787
+ if you want a specific subset). \`summary\`, \`found\`, and \`breakdown\`
788
+ are single-org commands and have **no** \`--slugs\`/\`--all-my-orgs\`
789
+ form; only \`organization\` does. The multi-org form rolls totals +
790
+ per-day / per-org-per-day averages + a per-org breakdown server-side
791
+ in **one** HTTP call.
792
+
793
+ **Anti-patterns to avoid:**
794
+
795
+ - \u274C "There's no cross-org aggregation in the CLI." There is \u2014
796
+ \`metrics organization --all-my-orgs\` (or \`--slugs\`). Don't bail
797
+ out citing the docs without trying these flags.
798
+ - \u274C Looping \`metrics summary --org X\` once per customer to sum
799
+ client-side. The multi-org form is one round-trip; the loop is what
800
+ made the endpoint 503-prone in the first place.
801
+ - \u274C Calling \`orgs list\` to build a slug list when you just want
802
+ "everything." Use \`--all-my-orgs\` and skip the enumeration entirely \u2014
803
+ the server resolves the same set via shared logic. Save \`orgs list\`
804
+ + \`--slugs\` for cases where the user asked for a specific subset.
805
+ - \u274C Routing the user to Metabase / the data warehouse for a question
806
+ the CLI can answer. Reach for Metabase only when the metric isn't
807
+ in the \`--include\` list (\`reports\`, \`newThreats\`,
808
+ \`threatsWatchlisted\`, \`takedownsFiled\`, \`takedownsCompleted\`,
809
+ \`domainThreats\`, \`twitterThreats\`, \`telegramThreats\`,
810
+ \`otherThreats\`, \`blockedByType\`, \`blockedByDay\`).
811
+ - \u274C "Iterating 100+ orgs one-by-one isn't practical here." Right \u2014
812
+ that's why you don't iterate. \`--all-my-orgs\` covers up to 500
813
+ orgs in a single call; for larger fleets, narrow with
814
+ \`--subscription-status\` / \`--service-active\`, or split an
815
+ explicit \`--slugs\` list into batches and sum.
816
+
817
+ #### Common cross-org recipe (copy and run)
818
+
819
+ The shortest answer to "how many takedowns across all customers in the
820
+ last 7 days?" is a single call \u2014 no \`orgs list\` step needed:
821
+
822
+ \`\`\`bash
823
+ chainpatrol --json metrics organization \\
824
+ --all-my-orgs \\
825
+ --subscription-status ACTIVE \\
826
+ --service-active takedowns \\
827
+ --include takedownsCompleted \\
828
+ --from <YYYY-MM-DD 7 days ago> --to <YYYY-MM-DD today>
829
+
830
+ # Read these fields from the JSON:
831
+ # .scope.orgs \u2190 which orgs the server resolved
832
+ # .metrics.takedownsCompleted \u2190 grand total across all orgs
833
+ # .averages.perDay.takedownsCompleted \u2190 total / windowDays
834
+ # .averages.perOrgPerDay.takedownsCompleted \u2190 total / numOrgs / windowDays
835
+ # .perOrg[slug].metrics.takedownsCompleted \u2190 per-customer breakdown
836
+ \`\`\`
837
+
838
+ Replace \`takedownsCompleted\` with whatever metric the user asked about.
839
+ Replace the date range with whatever window they asked about (default
840
+ 3 months if they didn't say).
841
+
842
+ If the user *asked* for a specific subset of customers ("how many for
843
+ acme, beta, gamma combined?"), use \`--slugs acme,beta,gamma\` instead
844
+ of \`--all-my-orgs\`. \`--slugs\` accepts up to 500 entries.
845
+
846
+ **Auth note for \`--all-my-orgs\`:** requires a user session or a
847
+ user-scoped API key (it inherits your memberships). Org-scoped API
848
+ keys are rejected \u2014 they're pinned to a single org by design. If
849
+ \`whoami\` shows an org-scoped key, use a Bearer session instead or
850
+ ask the user to provision a user API key.
851
+
852
+ #### Single-org examples
853
+
854
+ \`\`\`bash
855
+ chainpatrol --json metrics summary --org <slug> # defaults to last 3 months
856
+ chainpatrol --json metrics summary --org <slug> --this-week
857
+ chainpatrol --json metrics breakdown --org <slug> --by day --this-week
858
+ chainpatrol --json metrics found --org <slug> --from <YYYY-MM-DD> --to <YYYY-MM-DD>
859
+ chainpatrol --json metrics organization --org <slug> # defaults to last 3 months
860
+ \`\`\`
861
+
862
+ **Always operate on a bounded window.** When no \`--from\`/\`--to\`/\`--this-week\`
863
+ is passed, every metrics subcommand defaults to the trailing **last 3 months**
864
+ ending now. The default exists because unbounded org-wide aggregates over
865
+ multi-year history routinely time out at the platform layer (Vercel's
866
+ 30s function cap), which surfaces to clients as a 503. Stick to the default,
867
+ or pass an explicit narrower window \u2014 don't try to bypass the default by
868
+ guessing wide \`--from\` values.
869
+
870
+ The resolved range is echoed back in every output format so the user can
871
+ see exactly what they got:
872
+
873
+ - JSON: \`{ "range": { "startDate": "...", "endDate": "...", "label": "last 3 months" } }\`
874
+ - Markdown / human: the header line includes the label, e.g.
875
+ \`Organization metrics for acme \u2014 last 3 months\`, followed by
876
+ \`Range: <startDate> \u2192 <endDate>\`.
877
+
878
+ When reporting numbers to the user (especially averages and rates),
879
+ **state the window explicitly** \u2014 say "averaged over the last 3 months"
880
+ rather than just quoting a number, since the same prompt phrased
881
+ differently can pick a different window.
882
+
883
+ \`breakdown\` is the one you usually want for healthchecks: it returns a
884
+ time series (by day or week) of reports, new threats, watchlisted threats,
885
+ and takedowns filed/completed. Compare the latest period against a prior
886
+ window to spot the **spike** or **drop** signals described in the manual
887
+ HealthCheck Guide. \`summary\` returns a single window total; \`found\` is
888
+ oriented around when threats were first discovered; \`organization\` is
889
+ the full customer-facing dashboard slice (reports, new threats,
890
+ watchlisted, takedowns filed/completed, plus per-type and per-day
891
+ breakdowns).
892
+
893
+ #### \`--include\` \u2014 only compute the metrics you actually need
894
+
895
+ \`metrics organization\` runs one Prisma aggregate per requested field.
896
+ By default all 11 are computed in parallel. Pass \`--include\` (or
897
+ \`include: [\u2026]\` in the JSON body) with the comma-separated subset you
898
+ care about to skip the rest \u2014 the unrequested fields come back as
899
+ \`null\` instead of a number, and the server never runs those queries:
900
+
901
+ \`\`\`bash
902
+ # Only takedowns \u2014 one of the cheap shapes
903
+ chainpatrol --json metrics organization --org <slug> \\
904
+ --include takedownsFiled,takedownsCompleted
905
+
906
+ # Time series only, no scalar counts
907
+ chainpatrol --json metrics organization --org <slug> --include blockedByDay
908
+ \`\`\`
909
+
910
+ Allowed values: \`reports\`, \`newThreats\`, \`threatsWatchlisted\`,
911
+ \`takedownsFiled\`, \`takedownsCompleted\`, \`domainThreats\`,
912
+ \`twitterThreats\`, \`telegramThreats\`, \`otherThreats\`,
913
+ \`blockedByType\`, \`blockedByDay\`.
914
+
915
+ Use this whenever the user's question is specific ("how many takedowns
916
+ did we file last month?"). It is the lowest-effort way to make a
917
+ metrics call cheap enough to run repeatedly. Pair it with an explicit
918
+ date window for the best behavior.
919
+
920
+ #### \`--slugs\` \u2014 multi-org rollups in one call (use this for "across all customers/clients")
921
+
922
+ When the user asks for a total or an average **across more than one
923
+ org** \u2014 e.g. "how many takedowns did we complete across all clients
924
+ in the last 7 days?", "average reports per org per day this month",
925
+ "top 5 customers by new threats" \u2014 reach for \`--slugs\` instead of
926
+ looping. The server fans out the per-org aggregates internally,
927
+ sums into totals, computes per-day and per-org-per-day averages,
928
+ and returns a per-org breakdown in a **single HTTP round trip**:
929
+
930
+ \`\`\`bash
931
+ # Total takedowns completed across three customers, last 7 days
932
+ chainpatrol --json metrics organization \\
933
+ --slugs acme,beta,gamma \\
934
+ --include takedownsCompleted \\
935
+ --from 2026-05-12 --to 2026-05-19
936
+ \`\`\`
937
+
938
+ The response shape switches to multi-org:
939
+
940
+ \`\`\`json
941
+ {
942
+ "scope": { "mode": "multi", "orgs": ["acme", "beta", "gamma"] },
943
+ "metrics": { "takedownsCompleted": 117, ... }, // sum across orgs
944
+ "averages": {
945
+ "perDay": { "takedownsCompleted": 16.71, ... }, // total / windowDays
946
+ "perOrgPerDay": { "takedownsCompleted": 5.57, ... }, // total / numOrgs / windowDays
947
+ "windowDays": 7
948
+ },
949
+ "perOrg": { "acme": { "metrics": { ... } }, "beta": { ... }, "gamma": { ... } }
950
+ }
951
+ \`\`\`
952
+
953
+ To answer **"across all of our customers"**, prefer \`--all-my-orgs\` \u2014
954
+ it lets the server resolve the org set in one round-trip, no \`orgs
955
+ list\` step needed:
956
+
957
+ \`\`\`bash
958
+ chainpatrol --json metrics organization \\
959
+ --all-my-orgs \\
960
+ --subscription-status ACTIVE \\
961
+ --service-active takedowns \\
962
+ --include takedownsCompleted \\
963
+ --from 2026-05-12 --to 2026-05-19
964
+ \`\`\`
965
+
966
+ Use \`--slugs <comma-list>\` only when the user asked for a *specific*
967
+ subset of customers ("how many for acme, beta, gamma combined?"); the
968
+ two flags are mutually exclusive. Both forms cap at 500 orgs per call;
969
+ if a real fleet exceeds that, narrow with
970
+ \`--subscription-status\`/\`--service-active\` filters or split an
971
+ explicit \`--slugs\` list into batches and sum. **Do not loop
972
+ \`metrics organization\` once per org** \u2014 N HTTP round-trips is what
973
+ made the old code 503.
974
+
975
+ Always pair the multi-org form with \`--include\` to narrow the metric
976
+ set to what the user actually asked about. "How many takedowns did
977
+ we complete?" \u2192 \`--include takedownsCompleted\`; "average reports
978
+ per day per customer?" \u2192 \`--include reports\`. Skipping \`--include\`
979
+ runs ~11 aggregates per org which is rarely necessary.
980
+
981
+ #### Auth: which credential can use \`--slugs\` / \`--all-my-orgs\`
982
+
983
+ - **Org-scoped API key** (the most common production key): can only
984
+ query its own org. If \`--slugs\` contains foreign orgs the server
985
+ returns 403; \`--all-my-orgs\` is also rejected. Use the \`--org\`
986
+ form (or omit both) instead.
987
+ - **User API key**: inherits the user's org memberships, so it can
988
+ query any org the user is a member of (or any org for staff
989
+ users) via \`--slugs\` or \`--all-my-orgs\`. This is the credential
990
+ you want for cross-org rollups from automated agents.
991
+ - **Session auth** (Bearer token, e.g. \`chainpatrol login\`): same
992
+ membership rules as the user. Staff users can query any org.
993
+
994
+ #### Reporting numbers to the user
995
+
996
+ Whatever window and scope you choose, **make both explicit in your
997
+ reply** \u2014 say "averaged across 12 customers over the last 3 months"
998
+ or "summed across all paying orgs for the last 7 days." The same
999
+ prompt phrased slightly differently can pick a different window or
1000
+ org set, and the response already echoes
1001
+ \`scope.mode\` / \`scope.orgs\` / \`averages.windowDays\` /
1002
+ \`range.label\` so you don't have to guess.
1003
+
1004
+ ### \`presets list | run\` \u2014 Packaged workflows for common jobs
1005
+
1006
+ \`\`\`bash
1007
+ chainpatrol presets list
1008
+ chainpatrol presets run cs-weekly-health --org <slug>
1009
+ \`\`\`
1010
+
1011
+ Use \`presets list\` to discover packaged multi-step workflows. The bundled
1012
+ \`cs-weekly-health\` preset runs the standard customer-success weekly health
1013
+ sweep; prefer it over hand-rolling the same sequence of commands.
1014
+
1015
+ ## Headless / agent-mode tips
1016
+
1017
+ When running these commands from an agent or CI:
1018
+
1019
+ - Prefer \`--json\` (or \`--output json\`) so output is structured and the
1020
+ update-check stderr nudge is suppressed automatically.
1021
+ - Pass \`--no-input\` to forbid any interactive prompt (the CLI will error
1022
+ out instead of waiting on a TTY).
1023
+ - Pass \`--no-color\` or set \`NO_COLOR=1\` if your sink can't render ANSI.
1024
+ - Set \`CHAINPATROL_NO_UPDATE_CHECK=1\` to silence the skill/npm freshness
1025
+ nudge entirely.
1026
+ - For \`login\` specifically, see the headless runbook in the login section
1027
+ above \u2014 login is the one command that needs background + tail handling.
1028
+
1029
+ ## Checking Auth Status
1030
+
1031
+ To check if the user is logged in, read the credentials file:
1032
+
1033
+ \`\`\`bash
1034
+ cat ~/.chainpatrol/credentials.json 2>/dev/null && echo "Logged in" || echo "Not logged in"
1035
+ \`\`\`
1036
+
1037
+ Or start the login flow which will detect existing sessions:
1038
+ \`\`\`bash
1039
+ chainpatrol --json login
1040
+ \`\`\`
1041
+
1042
+ ## Configuration
1043
+
1044
+ Config is stored at \`~/.chainpatrol/config.json\`:
1045
+ - \`apiUrl\` \u2014 API base URL (default: \`https://app.chainpatrol.io\`)
1046
+ - \`defaultOrg\` \u2014 Saved organization slug
1047
+
1048
+ Override config dir with \`CHAINPATROL_CONFIG_DIR\` env var.
1049
+
1050
+ ## Version Checks
1051
+
1052
+ The CLI runs two lightweight version checks alongside each command and prints
1053
+ a nudge to stderr if anything is out of date:
1054
+
1055
+ - **Skill freshness**: compares the installed skill (\`~/.claude/skills/chainpatrol/SKILL.md\`)
1056
+ to the version bundled with the CLI. If it's missing or older, the user is
1057
+ asked to run \`chainpatrol setup\`.
1058
+ - **NPM freshness**: compares the running CLI version to the latest published
1059
+ on the npm registry. The check is throttled to once per 24 hours and capped
1060
+ at a 1.5s timeout, with the result cached at \`<configDir>/version-check.json\`.
1061
+
1062
+ Set \`CHAINPATROL_NO_UPDATE_CHECK=1\` to silence both checks. JSON mode
1063
+ (\`--json\`) and quiet mode (\`-q\` / \`--quiet\`) also suppress the nudges so
1064
+ machine-readable output is never polluted.
1065
+
1066
+ ## Global Flags
1067
+
1068
+ | Flag | Description |
1069
+ |------------------|--------------------------------------------------------|
1070
+ | \`--json\` | Machine-readable JSON output (shortcut for \`--output json\`) |
1071
+ | \`--output <fmt>\` | Output format: \`human\` (default), \`json\`, \`markdown\`, \`csv\` |
1072
+ | \`--quiet\`, \`-q\` | Suppress non-essential output and the update-check nudge |
1073
+ | \`--no-color\` | Disable ANSI colors (also respects the \`NO_COLOR\` env var) |
1074
+ | \`--no-input\` | Disable interactive prompts (use in scripts and agents) |
1075
+ | \`--org <slug>\` | Organization slug (saved as the default for later commands) |
1076
+ | \`--help\`, \`-h\` | Show help |
1077
+ | \`--version\` | Show version |
1078
+
1079
+ ## Workflow
1080
+
1081
+ When the user asks to use the CLI, follow this order:
1082
+
1083
+ 1. **Check login status** \u2014 Read \`~/.chainpatrol/credentials.json\` to see if they're logged in
1084
+ 2. **Login if needed** \u2014 Run the login command and guide them through the device code flow
1085
+ 3. **Set org if needed** \u2014 Ensure \`--org\` is provided or already saved in config
1086
+ 4. **Run the requested command** \u2014 Execute the CLI command and show results
1087
+
1088
+ ## Detection Config Output
1089
+
1090
+ The \`configs list\` command shows detection sources grouped by:
1091
+ - **Configured** \u2014 Sources with org-level configs (enabled/disabled with details)
1092
+ - **Global** \u2014 Sources that run globally for all orgs (CERTSTREAM, ASSET_CHECK, BLOCKLIST, etc.)
1093
+ - **Not Configured** \u2014 Sources available but not yet set up for the org
1094
+
1095
+ Each config entry includes: title, status, cron schedule, and configuration parameters.
1096
+
1097
+ ## Organization HealthCheck Guide
1098
+
1099
+ This guide explains how to look for things that may be wrong for a given org
1100
+ across the full pipeline: **detection \u2192 reviewing \u2192 blocklisting \u2192 takedowns**.
1101
+ When the user asks for a "health check", "audit", "what's wrong with org X",
1102
+ "review org X's setup", or similar, walk through each section below and surface
1103
+ findings.
1104
+
1105
+ In each section there are things you can look for that may be wrong. Some
1106
+ checks have a dedicated CLI command that does most of the work server-side;
1107
+ others are soft / qualitative signals that still need you to fetch data with
1108
+ \`configs list\` or \`reports list\` and reason about it manually.
1109
+
1110
+ ### Quick Path: CLI commands that automate parts of this guide
1111
+
1112
+ The canonical first step is now the \`healthchecks\` namespace, which runs
1113
+ every implemented check via the public API and returns a uniform shape per
1114
+ check (\`id\`, \`severity\`, \`observed\`, \`threshold\`, \`findings\`,
1115
+ \`suggestedAction\`):
1116
+
1117
+ \`\`\`bash
1118
+ # Discover every check the platform exposes, implemented or planned.
1119
+ chainpatrol --json healthchecks list
1120
+
1121
+ # Run every implemented healthcheck in parallel and aggregate the results.
1122
+ chainpatrol --json healthchecks run --all --org <slug>
1123
+
1124
+ # Run a single named check.
1125
+ chainpatrol --json healthchecks run reviewing.backlog --org <slug>
1126
+ \`\`\`
1127
+
1128
+ After \`healthchecks run --all\`, use these complementary commands to cover
1129
+ the signals that are not yet exposed as a uniform healthcheck endpoint:
1130
+
1131
+ \`\`\`bash
1132
+ # Spikes / drops in detection volume over time (compare windows)
1133
+ chainpatrol --json metrics breakdown --org <slug> --by day --this-week
1134
+
1135
+ # Customer-reported threats \u2014 gaps in our own detection
1136
+ chainpatrol --json reports list --org <slug> --reported-by-customer
1137
+
1138
+ # What's enabled vs disabled vs not configured for the org
1139
+ chainpatrol --json configs list --org <slug>
1140
+
1141
+ # Snapshot of review/takedown queues \u2014 raw counts behind several healthchecks
1142
+ chainpatrol --json queues snapshot --org <slug>
1143
+
1144
+ # Packaged weekly customer-success sweep (preferred when it covers the ask)
1145
+ chainpatrol presets run cs-weekly-health --org <slug>
1146
+ \`\`\`
1147
+
1148
+ Treat each command's output as one input to the healthcheck. The manual
1149
+ checks below still apply \u2014 especially for signals the CLI cannot infer on
1150
+ its own (e.g. "lots of Twitter assets are blocked but Twitter Post Search
1151
+ is disabled", or "this drop is fine because the config isn't relevant
1152
+ to this org"). Each subsection of the guide notes whether a healthcheck
1153
+ endpoint exists today and what to fall back on when it doesn't.
1154
+
1155
+ ### Reporting progress while running a healthcheck
1156
+
1157
+ When the user asks for a healthcheck, narrate each step in real time so they
1158
+ can watch the run unfold. Do NOT batch results and dump everything at the
1159
+ end. For every check you run (Quick Path CLI command, or a manual signal
1160
+ where you're fetching data with \`configs list\` / \`reports list\` to
1161
+ reason about):
1162
+
1163
+ 1. **Before** you call the command, emit ONE short sentence stating what
1164
+ you're about to check, including the org slug. Examples:
1165
+ - "Running detection config healthcheck for morpho\u2026"
1166
+ - "Snapshotting review and takedown queues for morpho\u2026"
1167
+ - "Fetching customer-reported reports for morpho to look for detection gaps\u2026"
1168
+
1169
+ 2. **As soon as** the command returns, emit ONE short result line that
1170
+ starts with a status word and ends with a key number or finding:
1171
+ - \`DONE\` \u2014 ran cleanly, nothing to flag
1172
+ - \`WARN\` \u2014 soft signal worth surfacing (e.g. a borderline backlog,
1173
+ mild spike or drop, a config you'd want a human to confirm)
1174
+ - \`FAIL\` \u2014 concrete failure that the user should act on
1175
+ - Examples:
1176
+ - "DONE \u2014 14/14 detection configs passing."
1177
+ - "WARN \u2014 23 proposals in the review queue; 4 are older than 7 days."
1178
+ - "FAIL \u2014 twitter_post_search returned 0 results in the last 24h with --run."
1179
+
1180
+ 3. Run **independent** checks in **parallel** (single message, multiple
1181
+ Bash tool calls) so progress lines arrive quickly. \`detections
1182
+ healthcheck\`, \`queues snapshot\`, \`metrics breakdown\`,
1183
+ \`reports list --reported-by-customer\`, and \`configs list\` are all
1184
+ independent of each other and safe to fire concurrently. Dependent
1185
+ follow-ups (e.g. paginating \`reports list\` with a returned cursor,
1186
+ or fetching extra detail on a single failing config) run after the
1187
+ first round.
1188
+
1189
+ 4. After every check is reported, emit a short final **Summary** section:
1190
+ - A one-line status per check (\u2713 / \u26A0 / \u2717 + name + key number).
1191
+ - A short "Top issues" list of the highest-priority FAIL / WARN
1192
+ findings, in priority order, with the concrete next action for each.
1193
+
1194
+ Keep each progress line to one sentence. The goal is for the user to see
1195
+ the healthcheck happening, not to read a wall of text mid-run \u2014 full
1196
+ detail belongs in the final Summary or in a follow-up when the user asks
1197
+ about a specific finding.
1198
+
1199
+ ### Detection
1200
+
1201
+ #### Enable Config That May Be Turned Off for Current Threats
1202
+
1203
+ Blocked threats exist in an asset type but the matching detection source is
1204
+ turned off. For example: lots of Twitter assets are on the blocklist, but
1205
+ detection sources like "Twitter / X User Search" or "Twitter Post Search" are
1206
+ disabled. Those should be turned on.
1207
+
1208
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed in
1209
+ \`healthchecks list\` as \`detections.coverage-gaps\` with
1210
+ \`implemented: false\` \u2014 when reporting this signal in a healthcheck, note
1211
+ "manual check, no API yet". Until the endpoint lands, do the correlation
1212
+ manually: \`chainpatrol --json configs list --org <slug>\` for enabled vs
1213
+ disabled configs, then \`chainpatrol --json reports list --org <slug>\` for
1214
+ recent blocked-item asset types. Flag any asset type where blocked items
1215
+ exist but the matching detection source has \`status: "disabled"\` (or
1216
+ appears in the "Not configured" group).
1217
+
1218
+ #### Spike in Detections
1219
+
1220
+ A spike in recent detections is worth investigating. It could be a bad config
1221
+ change, or it could be a legitimate new attack push in this area \u2014 useful
1222
+ intel to surface to the security team as a targeted spike.
1223
+
1224
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed
1225
+ in \`healthchecks list\` as \`detections.spike\` with \`implemented: false\`.
1226
+ Until the endpoint lands, use \`chainpatrol --json metrics breakdown --org <slug> --by day --this-week\`
1227
+ (and a comparison window via \`--from\`/\`--to\`) to see daily detection
1228
+ volume. Anything notably above the recent baseline is a spike \u2014 cross-reference
1229
+ against recent config changes for that source.
1230
+
1231
+ #### Drop in Detections
1232
+
1233
+ A drop is also worth looking into. It may be a bad config change, or it may
1234
+ mean the config is not really relevant and can be safely turned off (not all
1235
+ default-on configs are relevant to every org).
1236
+
1237
+ **Run via CLI:** the extreme case ("this source went silent") is covered
1238
+ today by \`chainpatrol --json healthchecks run detections.silent-configs --org <slug>\`,
1239
+ which is the canonical replacement for the older \`detections healthcheck\`.
1240
+ It fails any config whose \`recentResultCount\` is below \`--min-results\`
1241
+ in the \`--lookback-hours\` window; pass \`--run\` (via the lower-level
1242
+ \`detections healthcheck --run\`) to also catch configs that error when
1243
+ executed. For soft drops (still producing results but below baseline),
1244
+ \`detections.drop\` is marked \`implemented: false\` in \`healthchecks list\`
1245
+ \u2014 use \`metrics breakdown --by day\` and compare windows manually.
1246
+
1247
+ ### Reviewing
1248
+
1249
+ PENDING proposals split into two operationally distinct buckets:
1250
+
1251
+ - **Needs Review** \u2014 assets not on a watchlist, or reports submitted by a
1252
+ customer. This is the reviewing UI's default view (\`excludeWatchlisted=true\`)
1253
+ and the actionable queue reviewers work from. Pile-ups and aged items
1254
+ here are high priority \u2014 \`fail\` severity is reachable.
1255
+ - **Watchlisted** \u2014 pending proposals on watchlisted assets (excluding
1256
+ customer-reported reports). The UI hides these by default because
1257
+ watchlisting is the act of intentionally deferring the asset. Pile-ups
1258
+ and aged items here are worth surfacing as cleanup work but **severity
1259
+ is capped at warn** \u2014 they should never block on the same SLA as Needs
1260
+ Review.
1261
+
1262
+ Each bucket has its own pile-up and age check, so you can grade them
1263
+ independently and tune thresholds without one drowning the other.
1264
+
1265
+ #### Pile Up / Backlog of Needs-Review Proposals
1266
+
1267
+ Too many proposals waiting in review. For most organizations this is over 100
1268
+ reports, but really the threshold is relative to the average number of
1269
+ confirmed threats per week. Example: if an org only adds 5 blocked threats per
1270
+ week, then a 7-day backlog of even 10 proposals is a really big deal.
1271
+
1272
+ **Run via CLI:** **Implemented as \`healthchecks run reviewing.backlog\`.**
1273
+ The endpoint counts the **Needs Review** subset only (assets not
1274
+ watchlisted, or reports marked \`reportedByCustomer\`) and grades severity
1275
+ against per-org thresholds (default warn=50, fail=100; override with
1276
+ \`--warn-threshold\` / \`--fail-threshold\` via the run payload). This is
1277
+ the number the reviewing page in the app shows by default, so the
1278
+ healthcheck output matches what reviewers see.
1279
+
1280
+ For raw counts plus SLA / age breakdowns,
1281
+ \`chainpatrol --json queues snapshot --org <slug>\` remains useful and
1282
+ exposes \`reviewQueue.totalPendingProposals\` and
1283
+ \`reviewQueue.distinctReports\` (note: \`queues snapshot\` does NOT apply
1284
+ the watchlist filter, so its number is the sum of Needs Review +
1285
+ Watchlisted). Compare against the org's typical weekly throughput
1286
+ (use \`metrics summary --this-week\` for that baseline) \u2014 a backlog that
1287
+ exceeds a week of typical confirmed-threat volume is a finding regardless
1288
+ of the absolute number.
1289
+
1290
+ #### Really Old Needs-Review Proposals
1291
+
1292
+ Any Needs-Review proposal waiting longer than 14 days is a sign something
1293
+ has gone wrong. Even complex investigations rarely take longer than this.
1294
+ Except for rare cases, these should be rejected or approved to prevent a
1295
+ backlog from building.
1296
+
1297
+ **Run via CLI:** **Implemented as \`healthchecks run reviewing.old-proposals\`.**
1298
+ The endpoint counts Needs-Review proposals older than the warn / fail age
1299
+ thresholds (default 7 / 14 days) and lists the oldest offenders in
1300
+ \`findings\`. \`queues snapshot\` (\`reviewQueue.ageBuckets.gte168h\`) still
1301
+ works as a raw view, and \`reviewQueue.slaBuckets.breached\` captures the
1302
+ strictest SLA breaches separately \u2014 any non-zero value is worth raising.
1303
+
1304
+ #### Watchlist Pile-Up / Old Watchlisted Proposals
1305
+
1306
+ Watchlisted-pending proposals are deferred on purpose, but they shouldn't
1307
+ grow unbounded \u2014 a huge pile or very-old items signal that the watchlist
1308
+ needs a cleanup pass. These don't block on the same SLA as Needs Review.
1309
+
1310
+ **Run via CLI:** **Implemented as \`healthchecks run reviewing.watchlist-backlog\`**
1311
+ (pile-up count, default warn=200) and
1312
+ **\`healthchecks run reviewing.watchlist-old\`** (default warn-age 30
1313
+ days). Both cap severity at warn. When reporting findings during an org
1314
+ healthcheck, group them under "watchlist cleanup" rather than mixing with
1315
+ Needs-Review findings \u2014 they're operationally different concerns.
1316
+
1317
+ #### Spike in Auto Approved Reports
1318
+
1319
+ If suddenly a lot of proposals in an org are being approved by automation,
1320
+ that can be a sign of a bad rule approving too much, or a break in auto
1321
+ confidences. Sometimes detection is spamming things that uniquely combine
1322
+ with a weakness of a rule \u2014 which is effectively a bad rule. In all these
1323
+ cases, notify an engineer at ChainPatrol and check any detection configs you
1324
+ adjusted recently, since those may be the cause of spam combined with a weak
1325
+ rule.
1326
+
1327
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed
1328
+ in \`healthchecks list\` as \`reviewing.auto-approval-spike\` with
1329
+ \`implemented: false\`. As a proxy until the endpoint lands, use
1330
+ \`chainpatrol --json metrics breakdown --org <slug> --by day --this-week\`
1331
+ and look for a sudden surge in \`newThreats\` / \`threatsWatchlisted\` that
1332
+ isn't matched by a parallel rise in reviewer activity \u2014 that gap usually
1333
+ points at automation doing the approving.
1334
+
1335
+ ### Blocklisting
1336
+
1337
+ #### Google Safe Browsing (Coming Soon)
1338
+
1339
+ (Needs new public API added before this works.)
1340
+
1341
+ High error rate in Google Safe Browsing submission tracker. Each submission
1342
+ has a status. If too many are in \`CANCELLED\`, that means Google's engine
1343
+ denied our submission. Contact ChainPatrol's eng team to investigate why, and
1344
+ also take a look at the org's custom detection sources \u2014 it's possible there
1345
+ are too many false positives landing on the blocklist, indicating issues with
1346
+ detection and reviewing rules.
1347
+
1348
+ **Run via CLI:** **Not yet implemented as a healthcheck endpoint.** Listed
1349
+ in \`healthchecks list\` as \`blocklisting.gsb-cancelled-rate\` with
1350
+ \`implemented: false\`. Until Google Safe Browsing submission state is
1351
+ exposed in the public API, this remains a manual / engineering-team check.
1352
+
1353
+ ### Takedowns
1354
+
1355
+ The takedown pipeline has three stages \u2014 TODO (queued, not yet filed),
1356
+ IN_PROGRESS (filed, waiting on vendor / customer / refile), and a terminal
1357
+ state (COMPLETED or CANCELLED). Healthchecks cover pile-ups at each stage,
1358
+ plus quality/configuration issues.
1359
+
1360
+ #### Too Many Takedowns in ToDo
1361
+
1362
+ Can mean a gap in automated takedowns not being implemented for some new area
1363
+ of threats. It can also mean the areas that require manual takedowns are
1364
+ being missed by the takedown team.
1365
+
1366
+ **Run via CLI:** **Implemented as \`healthchecks run takedowns.todo-volume\`.**
1367
+ Counts takedowns sitting in TODO (default warn=50, fail=100). For raw
1368
+ breakdowns by type, cross-reference with
1369
+ \`chainpatrol --json metrics breakdown --org <slug> --by assetType\` \u2014
1370
+ items piled up on a specific platform usually point at an automation
1371
+ gap there.
1372
+
1373
+ #### Too Many Takedowns In Progress
1374
+
1375
+ Typically means something is wrong with the submission itself. The takedown
1376
+ may need to be resubmitted, the vendor asked for more evidence, or we may
1377
+ have submitted it in the wrong place.
1378
+
1379
+ **Run via CLI:** Two checks, complementary:
1380
+
1381
+ - **\`healthchecks run takedowns.in-progress-volume\`** \u2014 counts all
1382
+ IN_PROGRESS takedowns regardless of age (default warn=30, fail=75).
1383
+ Catches a vendor-side or submission-format problem before items go
1384
+ stale.
1385
+ - **\`healthchecks run takedowns.stale-in-progress\`** \u2014 counts IN_PROGRESS
1386
+ takedowns past a staleness threshold (default 7 days), lists the oldest
1387
+ offenders. Any non-zero value is worth investigating; a growing count
1388
+ across snapshots strongly suggests vendor-side or format issues.
1389
+
1390
+ #### Too Many Cancelled Takedowns
1391
+
1392
+ Takedowns should rarely be cancelled. A cancelled takedown means "we will not
1393
+ do this takedown" for some reason. Cases like adding an item to the blocklist
1394
+ when it's already taken down are treated as completed, not cancelled. So even
1395
+ 3 cancelled takedowns in a 7-day period is too many.
1396
+
1397
+ **Run via CLI:** **Implemented as \`healthchecks run takedowns.cancelled-count\`.**
1398
+ Counts transitions into the CANCELLED status from the TakedownEvent log
1399
+ within the lookback window (default 7 days, warn=3, fail=10). The check
1400
+ uses the event log rather than \`Takedown.updatedAt\` so it correctly
1401
+ attributes the cancellation date even if the takedown has since been
1402
+ edited. A spike usually means a quality problem in the proposal funnel
1403
+ or the CANCELLED status being used as a catch-all.
1404
+
1405
+ #### Automated Takedowns Turned Off for Over 30 Days
1406
+
1407
+ Automated takedowns should be on by default for nearly every organization.
1408
+ Any issue that would make you want to turn off automated takedowns should be
1409
+ resolved within 30 days.
1410
+
1411
+ **Run via CLI:** **Implemented as \`healthchecks run takedowns.automation-off\`.**
1412
+ Checks \`Organization.isAutomatedTakedownsActive\` and derives the
1413
+ off-duration from the most recent \`SERVICES_AUTOMATED_TAKEDOWNS_UPDATED\`
1414
+ entry in \`OrganizationEvent\` (default warn 30 days, fail 60 days). Orgs
1415
+ with takedown service entirely disabled (\`isTakedownsActive=0\`) are
1416
+ skipped \u2014 automation being off is implied in that case.
1417
+
1418
+ ### Assets
1419
+
1420
+ Healthchecks on the asset model \u2014 specifically asset liveness state, which
1421
+ the takedown team depends on for follow-up.
1422
+
1423
+ #### Spike in Recently Dead Assets
1424
+
1425
+ A sudden spike in DEAD detections can be a good signal (takedowns or platform
1426
+ moderation working) but it can also mean the liveness checker is
1427
+ misclassifying assets after a platform change, captcha rollout, or anti-bot
1428
+ update. If many assets become dead at once, sample a few manually.
1429
+
1430
+ **Run via CLI:** **Implemented as \`healthchecks run assets.dead-asset-spike\`.**
1431
+ Compares \`DETECTED_AS_DEAD\` events in the current window (default 24h)
1432
+ against the baseline rate from the prior \`baselineDays\` (default 7d).
1433
+ Severity fires only when the current count clears \`minSpikeCount\` (default
1434
+ 10) AND exceeds the multiplier (default warn \xD72, fail \xD74). The
1435
+ \`minSpikeCount\` floor suppresses noise on orgs with near-zero baseline
1436
+ activity. When this fires, pull a sample of recent DEAD assets, verify a
1437
+ few in a browser, and notify ChainPatrol engineering if the sample is
1438
+ clearly still live.
1439
+
1440
+ #### Assets Marked Dead but Still Online / Assets Not Marked Dead Even Though They Are Down
1441
+
1442
+ These two opposite failure modes are **not implemented as healthchecks**
1443
+ (listed as \`assets.dead-but-alive\` and \`assets.alive-but-marked-dead\` with
1444
+ \`implemented: false\`). Both require live HTTP probes against asset URLs,
1445
+ which is not a synchronous-healthcheck shape.
1446
+
1447
+ Until a dedicated probe command exists:
1448
+
1449
+ - For "marked dead but still alive": sample a handful of recently-DEAD
1450
+ assets, open them in a browser, and watch for any that load. Common
1451
+ causes: bot protection, geo-blocking, rate limits, or liveness logic
1452
+ that does not handle the asset type correctly.
1453
+ - For "alive but marked dead": after a known takedown event, sample
1454
+ assets that *should* be dead but are still marked alive. Common causes:
1455
+ cached responses, soft-404 pages, parked-domain redirects, platform
1456
+ suspension pages still returning 200.
1457
+
1458
+ In both cases, if liveness looks miscalibrated for a class of assets,
1459
+ notify ChainPatrol engineering \u2014 the checker likely needs a tuning pass for
1460
+ that platform.
1461
+
1462
+ ## Organization Trend Search Guide
1463
+
1464
+ Trend search asks "what's changed recently for this org?" \u2014 the answer can
1465
+ surface coordinated attacks, new attack channels, or campaigns targeting
1466
+ specific people, **before** they show up as a healthcheck failure. Unlike
1467
+ the HealthCheck Guide above (which grades single signals against
1468
+ thresholds), trend search compares a recent window to a baseline window
1469
+ and flags ratios, not absolute counts. A trend is interesting even when
1470
+ the pipeline is keeping up with it \u2014 the user usually wants to know.
1471
+
1472
+ When the user asks something like:
1473
+
1474
+ - "are there any trends in org X?"
1475
+ - "search for trends in <org>"
1476
+ - "anything unusual happening with <org> lately?"
1477
+ - "any spikes for <org>?"
1478
+ - "what's new for <org> this week?"
1479
+ - "is anyone targeting <org>'s employees more than usual?"
1480
+ - "are we seeing more YouTube/Telegram/etc. threats for <org>?"
1481
+
1482
+ \u2026run the three trend checks below in parallel (single message, multiple
1483
+ Bash calls) and surface anything where the current rate is \u2265 2\xD7 the
1484
+ baseline AND clears a small absolute floor.
1485
+
1486
+ ### How to compute "current vs. baseline" rates
1487
+
1488
+ Pick two non-overlapping windows: a **current** window the user cares about
1489
+ (default last 7 days) and a **baseline** window ending where the current
1490
+ one starts (default the prior ~90 days, i.e. \`current_start - 90d\` \u2192
1491
+ \`current_start - 1d\`). For any breakdown bucket, compute:
1492
+
1493
+ \`\`\`
1494
+ current_per_day = current_count / current_window_days
1495
+ baseline_per_day = baseline_count / baseline_window_days
1496
+ ratio = current_per_day / max(baseline_per_day, epsilon)
1497
+ \`\`\`
1498
+
1499
+ Flag a bucket if \`ratio >= 2\` AND \`current_count >= 5\`. The floor
1500
+ suppresses noise on orgs with near-zero baseline activity (a single new
1501
+ YouTube report jumping the rate from 0 to 1/day shouldn't trigger). If
1502
+ the user gives a different window ("last 3 days", "this month"), adjust
1503
+ both windows proportionally and keep the same ratio threshold.
1504
+
1505
+ ### Trend 1 \u2014 Spike in a specific asset type
1506
+
1507
+ A sudden jump in threats on a platform the org doesn't usually see
1508
+ traffic on ("normally you don't get targeted on YouTube much, but now
1509
+ there's a spike there") is worth flagging \u2014 it usually means an attacker
1510
+ has discovered a new channel that works for them. Even when the absolute
1511
+ number is small, the *ratio* against the org's normal mix is what
1512
+ matters.
1513
+
1514
+ Use \`metrics breakdown --by type\` over both windows:
1515
+
1516
+ \`\`\`bash
1517
+ # Current window \u2014 last 7 days, broken out by asset type
1518
+ chainpatrol --json metrics breakdown --org <slug> --by type \\
1519
+ --from <YYYY-MM-DD 7d ago> --to <YYYY-MM-DD today>
1520
+
1521
+ # Baseline window \u2014 prior ~90 days ending where the current window starts
1522
+ chainpatrol --json metrics breakdown --org <slug> --by type \\
1523
+ --from <YYYY-MM-DD 97d ago> --to <YYYY-MM-DD 8d ago>
1524
+ \`\`\`
1525
+
1526
+ Each entry in \`.points\` has \`{ type, count }\`. Join the two windows on
1527
+ \`type\`, apply the ratio rule above, and report each flagged type.
1528
+
1529
+ Cross-reference any flagged type with \`configs list --org <slug>\` \u2014 if
1530
+ the spike is on Twitter / X but \`twitter_post_search\` is disabled, the
1531
+ detection source for that channel isn't even running for this org and
1532
+ the spike is being caught by something else (likely customer reports);
1533
+ suggest turning it on.
1534
+
1535
+ ### Trend 2 \u2014 Spike in overall threat volume
1536
+
1537
+ A sharp rise in total threats across the org \u2014 regardless of type or
1538
+ brand \u2014 usually means a coordinated attack or campaign is underway. This
1539
+ isn't a healthcheck (reviewing and takedowns may be keeping up just
1540
+ fine), but the security team still wants to know so they can warn
1541
+ customers / employees / partners.
1542
+
1543
+ \`\`\`bash
1544
+ # Daily volume for the last ~6 weeks \u2014 enough to eyeball a baseline AND
1545
+ # see the spike on the right edge of the series.
1546
+ chainpatrol --json metrics breakdown --org <slug> --by day \\
1547
+ --from <YYYY-MM-DD 42d ago> --to <YYYY-MM-DD today>
1548
+ \`\`\`
1549
+
1550
+ Read \`.points\` (one entry per day). Take the trailing 7-day average and
1551
+ compare against the prior ~5 weeks (the same 2\xD7 / floor rule). For round
1552
+ totals to quote to the user, also pull:
1553
+
1554
+ \`\`\`bash
1555
+ # Two calls \u2014 current and baseline windows \u2014 using --include to skip
1556
+ # the per-type / per-day series and keep the call cheap.
1557
+ chainpatrol --json metrics organization --org <slug> \\
1558
+ --include reports,newThreats,threatsWatchlisted \\
1559
+ --from <current_from> --to <current_to>
1560
+
1561
+ chainpatrol --json metrics organization --org <slug> \\
1562
+ --include reports,newThreats,threatsWatchlisted \\
1563
+ --from <baseline_from> --to <baseline_to>
1564
+ \`\`\`
1565
+
1566
+ When volume spikes broadly, also skim \`reports list --reported-by-customer\`
1567
+ for the same window \u2014 a wave of customer reports often arrives a few hours
1568
+ ahead of automated detection on a real coordinated push.
1569
+
1570
+ ### Trend 3 \u2014 Spike on a specific sub-brand (especially employee brands)
1571
+
1572
+ Sub-brands the org has set up for individual people \u2014 employees,
1573
+ executives, public figures \u2014 are high-signal targets. A sudden spike on
1574
+ one usually means an attacker is impersonating that person specifically,
1575
+ which is materially different from a generic phishing wave and usually
1576
+ warrants a direct heads-up to the person involved. In the database these
1577
+ are \`Brand\` rows with \`type: INDIVIDUAL\` (vs. \`ORGANIZATION\` for
1578
+ product / parent brands).
1579
+
1580
+ **Step 1: Pull the brand roster** so you can label each spike as
1581
+ "employee" or "product" without asking the user.
1582
+
1583
+ \`\`\`bash
1584
+ chainpatrol --json brands list
1585
+ \`\`\`
1586
+
1587
+ Build a map of \`slug \u2192 type\` from the response so the next step's
1588
+ findings can be tagged \`(employee)\` or \`(product)\` automatically.
1589
+
1590
+ **Step 2: Run the breakdown over both windows.**
1591
+
1592
+ \`\`\`bash
1593
+ # Current window \u2014 last 7 days, broken out by sub-brand
1594
+ chainpatrol --json metrics breakdown --org <slug> --by brand \\
1595
+ --from <YYYY-MM-DD 7d ago> --to <YYYY-MM-DD today>
1596
+
1597
+ # Baseline window \u2014 prior ~90 days
1598
+ chainpatrol --json metrics breakdown --org <slug> --by brand \\
1599
+ --from <YYYY-MM-DD 97d ago> --to <YYYY-MM-DD 8d ago>
1600
+ \`\`\`
1601
+
1602
+ Each entry in \`.points\` has \`{ brandId, brandSlug, brandName, count }\`.
1603
+ Apply the ratio rule, join against the \`slug \u2192 type\` map from Step 1,
1604
+ and report each spiking sub-brand by name plus its type.
1605
+
1606
+ **Step 3: Drill into the flagged brand** with \`metrics organization
1607
+ --brand-slug <slug>\` for a per-day / per-type breakdown scoped to that
1608
+ brand only. The server applies the brand filter to the scalar metrics
1609
+ (\`newThreats\`, \`takedownsFiled\`, etc.) AND to \`blockedByType\` /
1610
+ \`blockedByDay\`, so the time series and per-asset-type counts are real
1611
+ brand-only data:
1612
+
1613
+ \`\`\`bash
1614
+ chainpatrol --json metrics organization --org <slug> \\
1615
+ --brand-slug <brand-slug> \\
1616
+ --include newThreats,blockedByType,blockedByDay \\
1617
+ --from <YYYY-MM-DD 7d ago> --to <YYYY-MM-DD today>
1618
+ \`\`\`
1619
+
1620
+ If multiple \`INDIVIDUAL\` brands are spiking at the same time, treat that
1621
+ as a stronger signal than a single one \u2014 likely a campaign targeting the
1622
+ company's people rather than a single impersonation. Prioritize those
1623
+ findings over single-brand spikes when summarizing.
1624
+
1625
+ ### Reporting trend findings
1626
+
1627
+ Report each spiking bucket as its own finding with: the trend it falls
1628
+ under (asset type / overall volume / sub-brand), the current vs. baseline
1629
+ rate (e.g. "youtube: 12/day last 7d vs. 1.2/day prior 90d, \xD710
1630
+ baseline"), and a one-line follow-up:
1631
+
1632
+ - Asset-type spike \u2192 check \`configs list\` for the matching detection
1633
+ source and turn it on if it's off.
1634
+ - Overall-volume spike \u2192 flag a possible coordinated campaign; suggest
1635
+ the security team look at the recent \`reports list\` for shared
1636
+ infrastructure (sender, registrar, hosting).
1637
+ - Sub-brand spike \u2192 look up \`type\` via \`brands list\`; if
1638
+ \`INDIVIDUAL\`, suggest a direct heads-up to that person; if
1639
+ \`ORGANIZATION\`, suggest a product-team alert.
1640
+
1641
+ If none of the three trends fire above the 2\xD7 / floor thresholds, say so
1642
+ explicitly ("no significant trends in the last 7 days vs. the prior 90")
1643
+ rather than dumping every breakdown number \u2014 the absence is the
1644
+ finding.
1645
+ `;
1646
+ }
1647
+
1648
+ // src/skill/parse.ts
1649
+ function parseSkillVersion(content) {
1650
+ const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
1651
+ if (!fmMatch) return void 0;
1652
+ const versionMatch = fmMatch[1].match(/^version:\s*(.+?)\s*$/m);
1653
+ return versionMatch ? versionMatch[1].trim() : void 0;
1654
+ }
1655
+
1656
+ exports.buildSkillContent = buildSkillContent;
1657
+ exports.parseSkillVersion = parseSkillVersion;
1658
+ //# sourceMappingURL=index.js.map
1659
+ //# sourceMappingURL=index.js.map