cloudflare/polystella/polystella-consumer
Claude Code and agent skill by cloudflare/polystella
- vendor
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Checking that the SKILL.md file is still in the repository.
Add or maintain PolyStella in an existing Astro project. Use when integrating AI-driven build-time content localization, configuring R2 caching, wiring locale-prefixed routes, or debugging an existing PolyStella setup in a downstream project.
Install
npx vskill@latest install cloudflare/polystella/polystella-consumerSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as cloudflare/polystella/polystella-consumer.
polystella-consumer
You are working in an Astro project that consumes the @cloudflare/polystella-astro package. This skill covers integration, configuration, common pitfalls, and the debug flow.
If you are working on the polystella package source itself (adding adapters, editing translators, modifying the cache layer), STOP and load polystella-contributor instead.
What PolyStella does
Build-time content localization for Astro:
- Translates content collections (
.md,.mdx,.toml,.json,.yaml) into additional locales using AI (Workers AI or Anthropic). - Caches translations in Cloudflare R2, content-addressed by source bytes + glossary + model. Unchanged content costs zero on rebuild.
- Injects routes under
/[lang]/...for each non-default locale. - Provides runtime APIs on
Astro.locals(t,lhref,getLocalizedEntry,getLocalizedCollection) and React hooks (useTranslations,useLocalizedHref). - Maintains UI strings via per-locale JSON dicts with drift detection, sync, and AI-fill subcommands.
Visitors get static bytes — no runtime AI calls.
Installation
Install from npm:
The standalone CLI binary is still named polystella.
Peer dependency: astro ^7.0.10.
Four-file integration
Set up these four files. The locale set lives in astro.config.mjs ONLY — everything else derives from it.
1. astro.config.mjs
2. polystella.config.mjs
Where provider, glossary, R2, format-specific keys live. The schema source of truth is packages/astro/src/config/options.ts in the repository; everything is zod-validated at the boundary.
Skeleton:
3. src/content.config.ts
4. src/env.d.ts
Picks up types for PolyStella's virtual modules (polystella:runtime-config).
Direct package use
Use the lower-level packages when Astro should not own the operation:
- Import translation contracts, glossaries, prompts, batching, and
PermanentProviderError from @cloudflare/polystella-core.
- Import portable format adapters from
@cloudflare/polystella-core/adapters.
- Import Workers AI and Anthropic factories from
@cloudflare/polystella-core/providers or its provider subpaths.
These packages use standard Web APIs and run in Workers without nodejs_compat; enabling nodejs_compat is also supported. The Astro package has no compatibility shims for low-level imports that moved to these owners.
UI strings
Chrome text (nav, footer, accessibility strings) lives in src/content/i18n/<locale>.json as flat key→string dicts. The default-locale file is the single source of truth; non-default locales must match its key set.
Workflow:
- Edit
src/content/i18n/en-US.json— add, remove, or change keys. - Run
polystella translate-uito propagate changes through other locales. - Spot-check translations; hand-edit any keys where you want exact wording. The AI step only fills _empty_ values, so a hand-written value stays untouched on subsequent runs.
- Commit. The pre-commit hook should run
polystella check-uiautomatically whensrc/content/i18n/is staged.
Strings are ICU messages with double outer braces. Every placeholder opens with {{ and closes with }}; branch bodies use single braces:
t("jobs.count", { count: 3 }) picks the branch with the locale's plural rules, so do not hand-roll interpolateLabel or .replace("{{x}}") helpers. Write '' for an apostrophe directly before {{, } or a plural #. For islands, pass the locale: useTranslations(dict, locale). Locale codes that are not BCP 47 tags (jp, es-la) need localeTags: { jp: "ja", "es-la": "es-419" } in polystella.config.mjs; the build fails until every code resolves to a tag Intl knows.
Wire the pre-commit hook (.githooks/pre-commit):
Catalog-Only Adoption
<a id="catalog-only-adoption"></a>
Use this path when a project wants PolyStella's JSON catalog flow but already owns content localization, routing, or collection lookups. It does not register translated content collections, route shims, R2 cache clients, or localized collection APIs.
Astro integration:
Manual middleware with explicit dictionaries:
The catalog middleware binds only Astro.locals.t and Astro.locals.lhref. The CLI commands still apply; use --base if the catalog directory is not ./src/content/i18n:
Entries that are not messages (inlang's $schema, variant-message arrays) go in catalog.ignoreKeys in polystella.config.mjs, never in the catalogAstro() or polystella() options. Patterns are regex strings matched against the whole dotted key: catalog: { ignoreKeys: ["\\$schema"] }. The CLI, the drift checks and catalogAstro() skip them and leave them untouched in locale files.
Catalogs written in standard single-brace ICU ({name}, inlang's ICU plugin) need catalog: { messageSyntax: "icu" } in the same file; the default "polystella" reads {{name}}. EmDash can't read that file: pass the same block as catalog in the polystellaEmdash() / polystellaEmdashAstro() options (catalog: polystellaConfig.catalog).
Catalog files accept two formats, auto-detected per file (all locale files must use the same format):
- Flat —
{ "site.title": "Cloudflare Blog" }. - Nested — groups flattened to the same dotted keys, so
t("site.title")
works identically in both formats:
``json { "site": { "i18n_group_title": "Site", "title": "Cloudflare Blog" } } ``
i18n_group_title is optional per-group metadata for tooling that reads the JSON; it is excluded from t() keys, drift checks, and AI translation.
Runtime APIs
In .astro files:
Outside .astro (utility scripts, getStaticPaths, React islands):
Branch-isolated R2 cache
Three modes, dispatched automatically by polystella.config.mjs:
| Mode | Env signals | r2.prefix | Writes? | |
|---|---|---|---|---|
| Local build | neither var set | i18n/ (read-only against main) | NO | |
| CI build (main) | WORKERS_CI_BRANCH=main | i18n/ | YES | |
| CI build (preview) | WORKERS_CI_BRANCH=<other> | previews/<branch>/i18n/ + fallback | YES (preview prefix only) | |
| Explicit CLI | POLYSTELLA_CLI=1 (set by cli.ts) | per resolved branch | YES |
Key mental model: a developer's local pnpm build can NEVER overwrite production. To populate R2 from outside CI, use the explicit polystella translate CLI.
Configure a lifecycle rule on the R2 bucket to expire previews/* after 30 days. The package only prunes within its configured prefix, so cross-build cleanup of orphan preview prefixes needs the lifecycle rule.
Override files (hand translations)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 25 Nov 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/polystella-consumer/SKILL.md
Popularity
- Repository stars
- 28
- Repository forks
- 3
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 May 2026, 6 months ago.
Extension points
hookPre/post lifecycle hooks
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cloudflare/polystella/polystella-consumer)