Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Astro Knowledge Patch?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nevaberry-astro-knowledge-patch)
---
name: astro-knowledge-patch
description: Astro
version: "7.4.13"
license: MIT
metadata:
author: Nevaberry
---
# Astro compatibility guidance
Load this skill when upgrading Astro or working on its content collections,
request pipelines, adapters, assets, security, configuration, or tooling.
Use the topic references for complete guidance, examples, and version-specific
experimental settings and migrations.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrading and breaking changes](references/upgrading-and-breaking-changes.md) | Node.js, Vite, dependencies, compiler validation, whitespace, queued rendering |
| [Content, data, and Actions](references/content-data-and-actions.md) | Collection loaders, IDs, schemas, live data, storage, Action types, React state, Astro DB |
| [Images, fonts, and styles](references/images-fonts-and-styles.md) | Responsive images, Sharp, SVG, APNG, image services, fonts, script and style output |
| [Markdown and MDX](references/markdown-and-mdx.md) | Processors, plugins, highlighting, punctuation, heading IDs, frontmatter, dynamic markup |
| [Routing, rendering, and caching](references/routing-rendering-and-caching.md) | Redirects, static paths, composable routing, cache providers, incremental builds, i18n, navigation |
| [Security, sessions, and environment](references/security-sessions-and-environment.md) | CSP, cookies, session storage, environment values, host and origin validation |
| [Adapters and integrations](references/adapters-and-integrations.md) | Cloudflare, Netlify, Vercel, Node, adapter hooks, prerenderers, frameworks, sitemaps |
| [Configuration, tooling, and APIs](references/configuration-tooling-and-apis.md) | Configuration helpers, servers, CLI, logging, builds, checking, container rendering |
| [Starlight](references/starlight.md) | Sidebar autogeneration, default-locale links, Chinese and Japanese spacing |
## Breaking changes and deprecations
### Runtime and compiler
- Astro 7.4.2 requires Node.js 22.23.4 or later. Starting with 7.4.3,
the CLI allows Node.js 22.22.0 or later inside WebContainers.
- Astro 7 uses Vite 8 with Rolldown. Update Vite 7 pins or overrides carried
forward from Astro 6; Vite translates `esbuild` and `rollupOptions` settings.
- The Rust compiler is the default for `.astro` files. Unclosed tags and
unterminated attributes are errors. JSX whitespace rules apply by default;
insert `{' '}` where a line break between inline elements needs a space.
- For string dynamic tag names in `.astro`, JSX, and MDX, only the leading valid
element name renders. A string starting with no valid name, including an
empty string, throws.
- `astro check` rejects TypeScript 7; its error points to the experimental
TypeScript 7.1 workflow using `@astrojs/ts-content-mapper` for `.astro` files.
### Markdown processor migration
Sätteri is the default for Markdown and MDX. Explicitly select `unified()` in
`markdown.processor` to retain remark or rehype plugins, or port those plugins
to Sätteri's MDAST or HAST plugin API.
Pass `remarkPlugins`, `rehypePlugins`, `remarkRehype`, `gfm`, and `smartypants`
to `unified()`. Their top-level `markdown` options are deprecated and will be
removed in Astro 8.0. Sätteri enables GFM by default; use
`satteri({ features: { math: true, headingAttributes: true } })` for math and
heading attributes.
Dynamic children of MDX `<script>` and `<style>` tags are escaped. Literal
markup, including markup inserted by remark or rehype plugins, remains raw.
Use `set:html` to render a trusted dynamic value as raw markup.
### Configuration migrations
| Earlier configuration or API | Migration |
| --- | --- |
| `experimental.session` | Remove the flag for stable sessions; configure storage in top-level `session`. |
| `experimental.svg` | Remove the flag for stable SVG components. |
| `experimental.serializeConfig` | Configuration imports work without the flag. |
| `experimental.responsiveImages`, `image.experimentalDefaultStyles` | Remove the flag; use `image.responsiveStyles` and `image.layout`. |
| `experimental.liveContentCollections` | Remove the opt-in flag for stable live collections. |
| `experimental.csp` | Move the policy to `security.csp`. |
| `experimental.cache`, `experimental.routeRules` | Move both settings to the top level. |
| `experimental.logger` | Move to top-level `logger`; `astro dev --json` selects JSON for one run. |
| `experimental.queuedRendering.enabled` | Drop the opt-in; queued rendering is stable and enabled by default. |
| `experimental.svgo` | Replace with experimental `experimental.svgOptimizer`. |
| `experimental_withState`, `experimental_getActionState` | Use `withState` and `getActionState` from `@astrojs/react/actions`. |
| Static `AstroCookies.consume(cookies)` | Use instance `cookies.consume()`; the static method remains supported but deprecated. |
### Asset and adapter contracts
- The Sharp service throws when rasterizing SVG unless
`image.dangerouslyProcessSVG: true` enables it for trusted SVG sources.
- `getImage()` options require choosing between `widths` and `densities` for
responsive variants; remove one from calls passing both.
- When wrapping `getStaticPaths()` in a custom prerenderer, return
`{ paths, metadata }` and preserve `metadata` even if you filter `paths`.
Astro uses this and render-result metadata to generate prerendered images;
bare paths arrays and bare `Response` results are deprecated and omit that data.
- A custom `FontProvider` can implement `getFontProperties({ familyName })`
returning `{ weights, styles, subsets, formats }`. Astro warns on unavailable
configured values; Astro 8 will require the callback for custom providers.
## Content collections and Actions
With Astro's base TypeScript template or a custom config, set both
`compilerOptions.strictNullChecks` and `compilerOptions.allowJs` to `true`.
For `glob()`, `slug` in frontmatter or JSON overrides the filename-derived ID,
including IDs with slashes; `generateId` changes generation across a collection.
`file()` uses an array item's `id` or a top-level object key, treats each
top-level TOML table as an entry, and accepts an optionally async `parser`.
`retainBody: false` leaves `entry.body` undefined while preserving `entry.filePath`
and, for Markdown, `entry.rendered.html`. `deferRender: true` renders entries
when a page renders them; its default is `false`, rendering during content sync.
`prerenderConflictBehavior` also controls duplicate `glob()` and `file()` IDs:
`'error'` fails content sync and `'ignore'` suppresses the warning.
Define live collections in `src/live.config.ts` with `defineLiveCollection()`.
Loaders return data at request time through `loadCollection` and `loadEntry`.
A supplied Zod schema validates and transforms at runtime, and its inferred
type takes precedence over the loader's type.
Configure an adapter and render live-query pages on demand; in static output
mode, set `export const prerender = false`. Queries return `{ entries, error }`
or `{ entry, error }`. Use build-time collections for MDX or image optimization.
Use `ActionInputSchema` from `astro:actions` with `z.input` to infer form inputs.
Malformed Action JSON returns `400 BAD_REQUEST`; invalid percent-encoding in
an action name returns `404 NOT_FOUND`.
## Routing, caching, and prerendering
Create `src/fetch.ts` with a default-exported fetch handler or Hono app to
control the pipeline. Register `astro()` from `astro/hono` after Hono middleware
that should run before Astro's built-in pipeline.
For a custom pipeline, register `notFound` before `pages()` to render a custom
404 page for unmatched routes. The built-in `astro()` handler already does this.
Propagate the `400 Bad Request` responses from `redirects()` and `actions()`
for over-encoded paths.
Configure `cache.provider`; use `Astro.cache.set()` in on-demand pages or
`context.cache.set()` in endpoints for lifetimes and tags. `Astro.cache.set(entry)`
associates the response with a content entry for invalidation. In an endpoint,
await `context.cache.invalidate()` with `tags` or `path` to purge responses.
`memoryCache()` skips responses that set cookies through `Astro.cookies` or
`Astro.session`, and responses with `Vary: Cookie` or `Vary: *`. An empty 404 or
500 response lets Astro render the corresponding error page on every request.
For experimental incremental builds, enable `experimental.incrementalBuild`
and return a data-sensitive `cacheKey` from `getStaticPaths()`. Reuse requires
both the key and module dependencies to match. Persist `node_modules/.astro/`
(the default cache directory) between CI builds. A collection entry's optional
`digest` is an opaque loader token; provide a separate data key if it is absent
and the page needs caching. Incremental reuse also works with
`build.concurrency` greater than `1`, including on Cloudflare.
For locales configured as `{ path, codes }`, use `path` in `i18n.defaultLocale`,
`i18n.fallback`, and `i18n.domains`. On-demand fallbacks use
`i18n.routing.fallbackType` and preserve query strings; explicit page statuses
and redirects take precedence.
## Security, sessions, and environment values
`security.csp` accepts `true` or a policy object and covers responsive image
styles. `'unsafe-inline'` suppresses generated hashes for its directive.
With `security.csp.scriptDirective.strictDynamic`, Astro adds bundled script
hashes to `script-src` and an import map with integrity data to the page head.
Astro validates forwarded host, protocol, and port together against one
`security.allowedDomains` entry. Forwarded protocols are limited to HTTP(S),
and applying a forwarded port requires an explicit port match. The Node adapter
also validates `Host` against `security.allowedDomains`.
For unsafe requests, `security.checkOrigin` applies when `Content-Type` is
absent or is `application/x-www-form-urlencoded`, `multipart/form-data`, or
`text/plain`. For Actions and on-demand endpoints it applies regardless of
whether or where composable `middleware()` is registered.
Set `session: false` to opt out. Astro excludes session runtime and dependencies
from the SSR bundle when no driver is wired. A session cookie must contain a
UUID before its value is used as a storage key. Partitioned cookies require
`secure: true`; cross-site iframe use typically also sets `sameSite: 'none'`.
An `astro:env` server secret stays out of client bundles and the generated
server build. With `experimental.staticImportMetaEnv`, private `import.meta.env`
values are inlined as strings; use `process.env` for runtime reads.
## Images and fonts
Set `image.layout` to `'constrained'`, `'fixed'`, or `'full-width'`; override it
with the `layout` prop on `<Image>` or `<Picture>`. `priority` sets eager loading,
synchronous decoding, and high fetch priority. Responsive styles use
`@layer astro.images`, so unlayered or higher-priority declarations can override.
Remote image optimization follows up to 10 redirects, with every URL checked
against `image.domains` or `image.remotePatterns`. Render `.apng` imports with a
native `<img>` to preserve animation; Astro image components reject APNG sources.
Use `image.service.build` for dev and prerendered pages, and
`image.service.runtime` for deployed on-demand pages and the image endpoint.
The minimum supported Sharp version is `0.35.4`.
Register fonts in top-level `fonts`. Render `Font` from `astro:assets` in the
head with the configured `cssVariable`, then use that variable in CSS.
With `fontProviders.local()`, supply faces through `options.variants` and `src`;
Astro tries to infer omitted weight and style. `<Font preload>` filters match
every field in at least one filter and can select a narrower variable-weight range.
## Adapters, CLI, and diagnostics
Cloudflare uses `workerd` for dev, prerendering, and production. Use
`cloudflare:workers` for bindings when migrating from `Astro.locals.runtime`.
In custom Worker fetch handlers, return any asset response from `cf()` before
the Astro pipeline, then call `finalize(state, response)` to apply cookies and
Cloudflare CDN cache defaults. Cloudflare's Hono middleware applies these headers.
Use `astro dev --background` or `astro preview --background` to detach after
readiness; manage the server with the corresponding `status`, `logs`, and `stop`
subcommands. `--ignore-lock` starts untracked foreground instances even when
agent detection would select background mode; explicit `--background` still
conflicts. Detected agents on Windows default to foreground mode.
Use top-level `logger` for logging destinations, `logHandlers.compose()` for
combined console and JSON output, and `AstroRuntimeLogger` for runtime types.
Errors after streaming begins reach the configured logger as one `error` record.
`astro build --timings` prints integration, Markdown, highlighting, and image
work timings. Experimental `parallelPrerender` uses all CPU cores minus one
or a configured worker count; each worker honors `build.concurrency` separately.
Adapters with their own prerenderer, including Cloudflare, ignore this flag.
`astro check` exits with code `1` for missing `@astrojs/check` or `typescript`
and reports the original error if the installed checker fails to load. Piped
output retains the result summary; an early pipe close exits with code `1`.