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-nevaberry-plugins)
---
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, caching, images, fonts, security, adapters, or tooling.
Use the topic references for complete examples and version-specific guidance,
including earlier experimental configuration and its later stable form.
## Reference index
| Reference | Topics |
| --- | --- |
| [Upgrading and breaking changes](references/upgrading-and-breaking-changes.md) | Node.js, dependencies, compiler validation, whitespace, rendering defaults |
| [Configuration, tooling, and APIs](references/configuration-tooling-and-apis.md) | Config imports, builds, CLI servers, checking, package installation, logging |
| [Content, data, and Actions](references/content-data-and-actions.md) | Loaders, IDs, schemas, live collections, storage, Actions, Astro DB |
| [Images, fonts, and styles](references/images-fonts-and-styles.md) | Responsive images, Sharp, SVG, font providers, downloads, preloading |
| [Markdown and MDX](references/markdown-and-mdx.md) | Processors, plugins, frontmatter, Markdown images, scripts and styles |
| [Adapters and integrations](references/adapters-and-integrations.md) | Cloudflare, Netlify, Vercel, Node, prerenderers, sitemaps, framework integrations |
| [Routing, rendering, and caching](references/routing-rendering-and-caching.md) | Redirects, URLs, request pipelines, i18n, cache invalidation, incremental builds |
| [Security, sessions, and environment](references/security-sessions-and-environment.md) | CSP, sessions, cookies, environment variables, host and origin validation |
| [Starlight](references/starlight.md) | Sidebar composition, alternate locale links, CJK spacing |
## Breaking changes and deprecations
### Runtime and compiler requirements
Astro 7.4.2 raised the minimum Node.js version to 22.23.4; 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
existing `esbuild` and `rollupOptions` settings to their Rolldown equivalents.
The Rust compiler is the default for `.astro` files. Unclosed tags and
unterminated attributes are errors. JSX whitespace rules apply by default;
insert `{' '}` when a line break between inline elements needs to render a space.
String tag names in `.astro` dynamic tags, JSX, and MDX render only their leading
valid element name and throw if the string starts with no valid name, including an empty string.
`astro check` rejects TypeScript 7 and points to the experimental workflow using
TypeScript 7.1 and `@astrojs/ts-content-mapper` for `.astro` checking.
### Markdown processor migration
Sätteri is the default for Markdown and MDX. Explicitly select `unified()` in
`markdown.processor` to keep remark or rehype plugins, or port them to Sätteri's
MDAST or HAST plugin API. Pass `remarkPlugins`, `rehypePlugins`, `remarkRehype`,
`gfm`, and `smartypants` to `unified()`; the corresponding top-level `markdown`
options are deprecated and will be removed in Astro 8.0.
### Configuration migrations
| Existing configuration | Migration |
| --- | --- |
| `experimental.session` | Remove the flag for stable sessions; use top-level `session` for storage configuration. |
| `experimental.svg` | Remove the flag for stable SVG components. |
| `experimental.serializeConfig` | Configuration imports are available without the flag. |
| `experimental.responsiveImages` | Remove the flag; set `image.layout` and replace `image.experimentalDefaultStyles` with `image.responsiveStyles`. |
| `experimental.liveContentCollections` | Remove the flag for stable live collections. |
| `experimental.csp` | Move to `security.csp`, accepting `true` or a policy options object. |
| `experimental.cache`, `experimental.routeRules` | Move both to the top level. |
| `experimental.logger` | Move to top-level `logger`; use `astro dev --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`, using `svgoOptimizer()` or a `SvgOptimizer` implementation. |
### API changes requiring edits
Replace React Action helpers `experimental_withState` and
`experimental_getActionState` with `withState` and `getActionState` from
`@astrojs/react/actions`. Use `cookies.consume()` instead of the deprecated,
still-supported static `AstroCookies.consume(cookies)` method.
When wrapping `getStaticPaths()` in a custom prerenderer, return `{ paths, metadata }`
and preserve `metadata` when filtering paths. Bare paths arrays and bare
`Response` results are deprecated and omit image data needed by prerendered pages.
The options type for `getImage()` requires choosing between `widths` and `densities`
for responsive variants. Astro's Sharp image service throws on SVG rasterization unless
`image.dangerouslyProcessSVG: true` enables
it for trusted sources. Use native `<img>` for APNG animation; Astro image
components reject APNG sources. The minimum supported Sharp version is `0.35.4`.
Custom font providers can implement `getFontProperties({ familyName })`, returning
`{ weights, styles, subsets, formats }`. Astro warns about unavailable configured
values; built-in providers implement it, and Astro 8 will require it for custom providers.
## Content collections and Actions
With the base TypeScript template or a custom config, set both
`compilerOptions.strictNullChecks` and `compilerOptions.allowJs` to `true`.
Collection schemas do not support custom image validation through `image().refine()`.
For `glob()`, entry `slug` overrides the filename-derived ID, including IDs with
slashes; `generateId` customizes collection-wide ID generation. For `file()`,
array item `id` fields or top-level object keys identify entries. Its optional
`parser` can be async and can extract nested JSON or handle formats such as CSV.
`retainBody: false` omits `entry.body` while keeping `entry.filePath` and Markdown's
`entry.rendered.html`. `deferRender: true` renders entries when a page renders them;
the default `false` renders during content sync and caches HTML.
Define live collections in `src/live.config.ts` with `defineLiveCollection()`.
Loader `loadCollection` and `loadEntry` methods return data at request time.
An optional Zod schema validates and transforms runtime data; its inferred type
takes precedence over the loader's type. Use an adapter and on-demand rendering.
`getLiveCollection(name, filter)` returns `{ entries, error }` and
`getLiveEntry(name, id)` returns `{ entry, error }`; a loader's typed entry filter
can replace the ID argument. If the loader supplies `rendered`, call `render(entry)`
and display `<Content />`. Use build-time collections for MDX or image optimization.
Use `ActionInputSchema` from `astro:actions` with `z.input` to infer form input types.
Malformed JSON action bodies return `400 BAD_REQUEST`; action names with invalid
percent-encoding return `404 NOT_FOUND`.
## Route caching and incremental builds
Configure a cache provider and use `routeRules` for groups of routes:
```js
import { defineConfig, memoryCache } from 'astro/config';
export default defineConfig({
cache: { provider: memoryCache() },
routeRules: { '/blog/[...path]': { maxAge: 300, swr: 60 } },
});
```
Use `Astro.cache.set()` in on-demand pages or `context.cache.set()` in endpoints
for lifetimes and tags. `Astro.cache.set(entry)` associates a content entry for
invalidation. Await `context.cache.invalidate({ tags: ['products'] })` or
`context.cache.invalidate({ path: '/products/widget' })` in an API endpoint.
`memoryCache()` skips responses that set cookies through `Astro.cookies` or
`Astro.session`, and responses with `Vary: Cookie` or `Vary: *`. When a page returns
an empty 404 or 500, `memoryCache()` lets Astro render the corresponding error page on every request.
Experimental incremental builds require `experimental.incrementalBuild` and a
`cacheKey` from `getStaticPaths()` that changes with page data. Dynamic pages are
reused only when that key and module dependencies match the previous build.
Persist `node_modules/.astro/` (the default cache directory) between CI builds.
Entry `digest` values are optional opaque change tokens: supply a separate data
key when the loader omits one and the page needs caching.
Incremental caching works with `build.concurrency` greater than `1`, including
the Cloudflare adapter. Experimental `parallelPrerender` uses all available CPU cores minus one, or
accepts `{ workers: 4 }`; each worker honors `build.concurrency` independently.
Adapters with their own prerenderer, including `@astrojs/cloudflare`, ignore that flag.
## Request pipelines and localization
Use `src/fetch.ts` to export a fetch handler or Hono app. Register `astro()` from `astro/hono`
after middleware that should run before the built-in pipeline. For a custom
pipeline, register `notFound` before `pages()` to render custom 404 pages;
the built-in `astro()` handler already does this.
Composable `trailingSlash()`, `redirects()`, `actions()`, `middleware()`, and
`pages()` return `400 Bad Request` for over-encoded paths. Custom pipelines
should propagate that response from `redirects()` and `actions()`.
For locales configured as `{ path, codes }`, use `path` in `i18n.defaultLocale`,
`i18n.fallback`, and `i18n.domains`. Browser-language matching handles casing and
separator differences. On-demand fallback rewrites or redirects preserve the
query string; explicit page statuses and redirects take precedence.
## Security, sessions, and environment
`security.csp` covers responsive image styles. With
`security.csp.scriptDirective.strictDynamic`, Astro adds bundled script hashes
and an import map with integrity data. Adding `'unsafe-inline'` as a CSP resource
suppresses generated hashes for that directive.
`security.checkOrigin` applies to Actions and on-demand endpoints regardless of
registration or omission of `astro/hono`'s `middleware()`. For unsafe requests,
it applies when `Content-Type` is absent or is `application/x-www-form-urlencoded`,
`multipart/form-data`, or `text/plain`.
Astro validates forwarded host, protocol, and port together against one
`security.allowedDomains` entry. Applying a forwarded port requires an explicit port match.
The Node adapter validates `Host` against that allowlist, and domain-based i18n also respects it.
Set `session: false` to disable sessions. Session cookie IDs must be UUIDs before
being used as storage keys. 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. `experimental.staticImportMetaEnv` inlines private `import.meta.env` values
as strings; use `process.env` for values needed at runtime.
## Images, fonts, and adapter runtime
Use `image.layout` for responsive defaults and `<Image>` or `<Picture>` `layout`
for overrides. `priority` sets eager loading, synchronous decoding, and high fetch
priority. Responsive styles use `@layer astro.images` and can be overridden by
unlayered declarations or a higher-priority layer.
Set `image.service.build` for dev and prerendered pages, and `image.service.runtime`
for deployed on-demand pages and the image endpoint. Remote optimization follows
up to 10 redirects; every URL must match `image.domains` or `image.remotePatterns`.
Register fonts in top-level `fonts`. Use `<Font preload>` filters for weight,
style, or subset; a variant must match every field of at least one filter.
Local variants use `fontProviders.local()` and `options.variants` with `src` paths.
The Cloudflare adapter uses `workerd` for development and prerendering as well as production;
access bindings through `cloudflare:workers`. In custom Worker fetch handlers,
call `finalize(state, response)` after the Astro pipeline to apply cookies and
Cloudflare CDN cache defaults. The Cloudflare Hono middleware applies these automatically.
## CLI and diagnostics
Use `astro dev --background` or `astro preview --background` for managed servers,
and their `status`, `logs`, and `stop` subcommands to manage them. `--ignore-lock`
starts an untracked foreground instance, including when agent detection would
otherwise select background mode; explicit `--background` still conflicts.
Detected agents on Windows run dev and preview in the foreground by default.
Run `astro build --timings` for the build timing summary. Configure `logger` with
`logHandlers.compose()` for console and JSON destinations. Image-service and
cache-provider hook logs respect destination, level, and `--silent`; streaming
errors produce a single `error` record in development and production.