Skip to content

Commit 3d0e331

Browse files
Add reference docs, Cloudflare examples, and test runner
- Split SKILL.md into focused reference docs: PREDICTIONS.md, MODEL_SEARCH.md, COLLECTIONS.md, WORKFLOWS.md, DEPLOYMENTS.md, HTTP_API.md, CLOUDFLARE_WORKERS.md, CLOUDFLARE_WORKFLOWS.md - Add Cloudflare Workers examples: basic, async poll, concurrent, image editing via request.blob(), routing by path - Add Cloudflare Workflows example: keyframe → video → stitch pipeline - Vary models across examples (p-image, flux-2-klein, flux-schnell) - Add script/test_snippets.py: extracts and runs all code snippets, spins up wrangler dev for worker/workflow snippets, detects image inputs and POSTs test fixture - Add ruff check/format to script/lint - Add test-snippets job to CI (skipped on fork PRs) - Update greger-skill.el to list sibling .md reference file paths - Update AGENTS.md with new structure and testing docs
1 parent 8c871d6 commit 3d0e331

17 files changed

Lines changed: 3739 additions & 65 deletions

.github/workflows/ci.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,33 @@ jobs:
1717
- name: Run lint
1818
run: script/lint
1919

20+
test-snippets:
21+
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.12"
30+
- name: Set up uv
31+
uses: astral-sh/setup-uv@v3
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v4
34+
with:
35+
node-version: "22"
36+
- name: Install npm dependencies
37+
run: npm install --silent
38+
working-directory: test
39+
- name: Run snippet tests
40+
env:
41+
REPLICATE_API_TOKEN: ${{ secrets.REPLICATE_API_TOKEN }}
42+
run: python script/test_snippets.py
43+
2044
publish-clawhub:
2145
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
22-
needs: lint
46+
needs: [lint, test-snippets]
2347
runs-on: ubuntu-latest
2448
steps:
2549
- name: Checkout

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
*.swp
33
*.swo
44
*~
5+
node_modules/
6+
__pycache__/
7+
*.greger

AGENTS.md

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,49 @@
22

33
## Purpose
44

5-
This repo publishes a single Agent Skills document for Replicate.
6-
7-
Keep it short and focused: a human- and agent-readable guide to discovering models, inspecting schemas, running predictions, and handling outputs.
5+
This repo publishes Agent Skills for Replicate: a main skill document plus focused reference docs covering predictions, model search, collections, workflows, deployments, Cloudflare integration, and the HTTP API.
86

97
## Files that matter
108

11-
- `skills/replicate/SKILL.md` is the canonical skill.
12-
- `.mcp.json` points to the remote MCP server.
13-
- `.claude-plugin/` contains marketplace metadata for Claude Code.
9+
- `skills/replicate/SKILL.md` — the main skill (overview, common patterns, reference table).
10+
- `skills/replicate/references/*.md` — detailed reference docs linked from SKILL.md.
11+
- `script/lint` — validates the skill and lints Python with ruff.
12+
- `script/test_snippets.py` — extracts and runs every code snippet from the markdown files.
13+
- `test/fixtures/` — test assets (e.g. images for workers that accept file uploads).
14+
- `.mcp.json` — points to the remote MCP server.
15+
- `.claude-plugin/` — marketplace metadata for Claude Code.
1416

1517
## Editing guidelines
1618

17-
- Keep `SKILL.md` concise and practical. Prefer bullet lists over long prose.
19+
- Keep `SKILL.md` concise. Detailed examples go in `references/`.
20+
- Every code snippet must be runnable. The test runner executes them all.
21+
- Snippets starting with `// worker.js` or `// workflow.js` are tested via `wrangler dev`.
22+
- Snippets whose worker reads `request.blob()` or `request.arrayBuffer()` get a test image POSTed automatically.
1823
- Treat `https://api.replicate.com/openapi.json` as the source of truth.
19-
- Keep mentions of deprecated or unofficial endpoints out of the skill.
2024
- Do not add language-specific client guidance unless explicitly requested.
2125

2226
## Linting
2327

24-
Lint before committing changes:
25-
2628
```
2729
script/lint
2830
```
31+
32+
## Testing
33+
34+
Runs all code snippets (bash, python, javascript) from every markdown file:
35+
36+
```
37+
REPLICATE_API_TOKEN=... python script/test_snippets.py
38+
```
39+
40+
Syntax check only (no API calls):
41+
42+
```
43+
REPLICATE_API_TOKEN=... python script/test_snippets.py --syntax-only
44+
```
45+
46+
Test a single reference file:
47+
48+
```
49+
REPLICATE_API_TOKEN=... python script/test_snippets.py --include references/CLOUDFLARE_WORKERS.md
50+
```

script/lint

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/bin/sh
22

3-
# script/lint: Validate Agent Skills definitions with skills-ref.
4-
# skills-ref is the reference CLI for the Agent Skills spec (agentskills.io).
5-
# It provides the `agentskills` executable with a `validate` subcommand.
6-
# Uses uvx if available for a clean, isolated install of the validator.
7-
# Falls back to a local Python module install if uv is not present.
3+
# script/lint: Validate Agent Skills definitions with skills-ref,
4+
# then lint and format Python scripts with ruff.
85

96
set -e
107

@@ -18,17 +15,21 @@ echo "==> Validating Agent Skills in $SKILL_PATH"
1815

1916
if command -v uv >/dev/null 2>&1; then
2017
uvx --from skills-ref agentskills validate "$SKILL_PATH"
21-
exit 0
22-
fi
23-
24-
PYTHON_BIN="${PYTHON_BIN:-python3}"
25-
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
26-
if command -v python >/dev/null 2>&1; then
27-
PYTHON_BIN=python
28-
else
29-
echo "python not found. Install Python 3 or uv to run skills-ref." >&2
30-
exit 1
18+
else
19+
PYTHON_BIN="${PYTHON_BIN:-python3}"
20+
if ! command -v "$PYTHON_BIN" >/dev/null 2>&1; then
21+
if command -v python >/dev/null 2>&1; then
22+
PYTHON_BIN=python
23+
else
24+
echo "python not found. Install Python 3 or uv to run skills-ref." >&2
25+
exit 1
26+
fi
3127
fi
28+
"$PYTHON_BIN" -m skills_ref validate "$SKILL_PATH"
3229
fi
3330

34-
"$PYTHON_BIN" -m skills_ref validate "$SKILL_PATH"
31+
echo "==> Linting Python (ruff check)"
32+
uvx ruff check script/test_snippets.py
33+
34+
echo "==> Formatting Python (ruff format --check)"
35+
uvx ruff format --check script/test_snippets.py

0 commit comments

Comments
 (0)