ericrisco/rsc-harness / skills/replicate
replicate
VerifiedUse when running, packaging, deploying or scaling a model on the Replicate platform from code — blocking run versus async predictions, handling FileOutput, deployments with warm private endpoints and autoscaling, packaging with Cog, verifying webhook signatures, and cutting GPU spend. NOT crafting image prompts and parameters or picking image model families (that is `replicate-images`).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.3 KB |
| evals/README.md | markdown | 685 B |
| evals/cases.yaml | config | 3.0 KB |
| references/cog-packaging.md | markdown | 4.3 KB |
| references/deployments-api.md | markdown | 3.0 KB |
| references/webhooks-and-async.md | markdown | 4.0 KB |
| scripts/verify.shexecutable | script | 6.0 KB |
references/webhooks-and-async.md
View on GitHub# Webhooks & async — full reference
Source: https://replicate.com/docs/topics/webhooks/verify-webhook and the client READMEs
(accessed 2026-06-02).
## Event filters
`webhook_events_filter` controls which lifecycle events POST to your URL. Filter to what you need —
`["completed"]` for most apps, add `"start"`/`"output"`/`"logs"` only if you stream progress.
```python
client.predictions.create(
model="owner/model",
input={"prompt": "..."},
webhook="https://your.app/hooks/replicate",
webhook_events_filter=["completed"],
)
```
## Signature verification — Python
Replicate signs every delivery. The secret (fetch once from the API / dashboard) has a `whsec_`
prefix. Signed content is `{webhook-id}.{webhook-timestamp}.{raw-body}`. Verify before trusting:
```python
import base64, hashlib, hmac
def verify_replicate_webhook(headers: dict, raw_body: bytes, signing_secret: str) -> bool:
webhook_id = headers["webhook-id"]
timestamp = headers["webhook-timestamp"]
signature_header = headers["webhook-signature"] # e.g. "v1,<b64sig> v1,<b64sig2>"
secret_bytes = base64.b64decode(signing_secret.split("_", 1)[1]) # strip "whsec_"
signed_content = f"{webhook_id}.{timestamp}.{raw_body.decode()}".encode()
expected = base64.b64encode(
hmac.new(secret_bytes, signed_content, hashlib.sha256).digest()
).decode()
# header may carry multiple space-separated "v1,<sig>" tokens; match any
for token in signature_header.split():
_, _, sig = token.partition(",")
if hmac.compare_digest(sig, expected):
return True
return False
```
- Use the **raw** request body bytes, not a re-serialized JSON dict — re-serialization changes bytes
and breaks the HMAC.
- Always `hmac.compare_digest` (constant time), never `==` — `==` leaks timing.
- Optionally validate the `webhook-timestamp` is recent (reject if older than ~5 min) to blunt replay.
## Signature verification — Node
```javascript
import crypto from "node:crypto";
export function verifyReplicateWebhook(headers, rawBody, signingSecret) {
const id = headers["webhook-id"];
const timestamp = headers["webhook-timestamp"];
const sigHeader = headers["webhook-signature"]; // "v1,<b64> v1,<b64>"
const secretBytes = Buffer.from(signingSecret.split("_")[1], "base64"); // strip "whsec_"
const signedContent = `${id}.${timestamp}.${rawBody}`;
const expected = crypto.createHmac("sha256", secretBytes)
.update(signedContent).digest("base64");
return sigHeader.split(" ").some((tok) => {
const sig = tok.split(",")[1];
const a = Buffer.from(sig);
const b = Buffer.from(expected);
return a.length === b.length && crypto.timingSafeEqual(a, b);
});
}
```
The official clients also expose a built-in helper — prefer it when available; the manual recipe above
is for frameworks where you only have raw headers + body.
## Idempotency
Webhooks can be delivered more than once. Dedupe on the `webhook-id` header (store processed ids,
skip repeats) so a retry does not double-charge a user or re-run side effects.
## 5xx and retries
Return `2xx` fast once you have verified + enqueued the work. If your handler returns a `5xx`,
Replicate retries — so keep the handler thin (verify, persist, enqueue) and do heavy work
asynchronously. A handler that does slow work inline risks timing out and getting retried, compounding
load.
## Polling loop with backoff (when you don't use webhooks)
```python
import time
def wait_for(client, prediction, max_wait=600):
deadline = time.monotonic() + max_wait
delay = 1.0
while prediction.status not in ("succeeded", "failed", "canceled"):
if time.monotonic() > deadline:
prediction.cancel()
raise TimeoutError("prediction exceeded max_wait")
time.sleep(delay)
delay = min(delay * 1.5, 10.0) # capped exponential backoff
prediction.reload()
return prediction
```
Prefer webhooks for long jobs — polling ties up a process. Set a server-side prediction **deadline**
too so a job auto-cancels even if your poller dies.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |