mirror of
https://github.com/tiennm99/claude-code-routine-trigger.git
synced 2026-10-16 16:15:26 +00:00
4.2 KiB
4.2 KiB
phase, title, status, priority, effort, dependencies
| phase | title | status | priority | effort | dependencies | ||
|---|---|---|---|---|---|---|---|
| 3 | wrangler config + secrets | completed | P1 | 1h |
|
Phase 3: wrangler config + secrets
Overview
Author wrangler.toml with literal [triggers].crons, define plain vars vs secrets, document deployment flow. CF Workers cron triggers fire from wrangler.toml only — same constraint as GH Actions.
Requirements
- Functional:
wrangler deploysucceeds with validwrangler.toml.- At least one cron expression in
[triggers](default 5×daily mirroring sibling repos). - Secrets uploaded out-of-band (not in
wrangler.toml).
- Non-functional:
- All comments above each block explain the field.
- Default crons use scattered minutes (avoid minute
0) perclaude-code-routine-triggerREADME warning — though CF cron is more reliable than GH, scattering is still good hygiene.
Architecture
wrangler.toml shape
name = "claude-code-routine-trigger-worker"
main = "worker.js"
compatibility_date = "2026-05-09"
compatibility_flags = ["nodejs_compat"] # only if Intl needs polyfill — verify in phase 2
# Plain vars (visible in dashboard, fine for non-secrets)
[vars]
TEXT_TEMPLATE = "Scheduled trigger at {LocalTime}"
TZ = "Asia/Ho_Chi_Minh"
# Cron triggers — LITERAL, cannot read from env/secrets/vars
[triggers]
crons = [
"7 17 * * *", # 00:07 UTC+7
"13 22 * * *", # 05:13 UTC+7
"19 3 * * *", # 10:19 UTC+7
"23 8 * * *", # 15:23 UTC+7
"37 13 * * *", # 20:37 UTC+7
]
# Observability — opt-in, free tier supports basic logs
[observability]
enabled = true
Secrets (uploaded via wrangler secret put)
| Name | Source |
|---|---|
ROUTINE_FIRE_URL |
Anthropic routine editor → API trigger |
ROUTINE_FIRE_TOKEN |
Anthropic routine editor (shown once) |
Local dev: .dev.vars
ROUTINE_FIRE_URL=https://api.anthropic.com/v1/claude_code/routines/trig_.../fire
ROUTINE_FIRE_TOKEN=sk-ant-oat01-...
Gitignored. Used by wrangler dev only.
wrangler.toml.example
Committed copy with placeholder values for documentation; real wrangler.toml ships with author's defaults but secrets are NEVER literal.
Related Code Files
- Create:
wrangler.toml - Create:
wrangler.toml.example(or document in README — KISS, prefer README) - Create:
.dev.vars.examplewith placeholder secret names + dummy values
Implementation Steps
- Write
wrangler.tomlper architecture block above.- Pick
compatibility_date= today (2026-05-09). - Decide on
nodejs_compatflag — only enable if phase 2 needs it (Intlis built-in, likely don't need it).
- Pick
- Write
.dev.vars.example:ROUTINE_FIRE_URL=https://api.anthropic.com/v1/claude_code/routines/trig_REPLACE/fire ROUTINE_FIRE_TOKEN=sk-ant-oat01-REPLACE - Verify
.gitignoreincludes.dev.vars(added in phase 1). - Local validation:
wrangler dev— must boot without error. - Document secret-upload flow in phase 5 README:
echo -n 'https://...' | wrangler secret put ROUTINE_FIRE_URL echo -n 'sk-ant-oat01-...' | wrangler secret put ROUTINE_FIRE_TOKEN - Commit:
feat: wrangler config with default 5x-daily crons.
Success Criteria
wrangler devstarts cleanly with.dev.varspopulatedwrangler deploy --dry-runvalidateswrangler.tomlwithout errors- All 5 default crons match sibling repos' cadence (UTC+7 daily 00/05/10/15/20)
- No secret values in any committed file
.dev.varsconfirmed in.gitignore
Risk Assessment
- CF cron expression syntax: CF Workers cron supports standard 5-field;
*/Nand ranges work. Avoid?(Quartz-only). - Minute-
0GH issue does not apply to CF but scattering minutes is still recommended (free tier shared infra benefits). - Free tier limit: 5 cron triggers per worker. Default config uses exactly 5 — at limit. Document that adding a 6th requires another worker.
Security Considerations
- Secrets never in
wrangler.toml(only[vars]for non-secrets). .dev.varsis gitignored.wrangler secret putaccepts stdin, avoiding shell history leak (useecho -n ... | wrangler secret put).