Skip to content

Commit fd7b908

Browse files
committed
feat: AI-Native support for Astro Strapi Starter with Skills, AGENTS.md, and Cursor Rules
1 parent 605dfdf commit fd7b908

17 files changed

Lines changed: 1602 additions & 1450 deletions

File tree

.ai/AGENTS.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Agent instructions: Astro × Strapi starter
2+
3+
This project is a production-oriented **Astro 6** frontend with **Strapi 5** content loaded via [**@sensinum/astro-strapi-loader**](https://github.com/VirtusLab-Open-Source/astro-strapi-loader) and **Strapi 5 rich-text Blocks** rendered with [**@sensinum/astro-strapi-blocks**](https://github.com/VirtusLab-Open-Source/astro-strapi-blocks). Styling uses **Tailwind CSS 4** (Vite plugin) and **shadcn/ui**-style components.
4+
5+
The `.ai/` directory holds **portable, tool-agnostic** context. A thin [`AGENTS.md`](../AGENTS.md) at the repository root points here so tools that only scan the project root can find these instructions.
6+
7+
## Where to look first
8+
9+
| Topic | In this repo | Canonical upstream (not vendored) |
10+
|--------|--------------|-----------------------------------|
11+
| **This template** (collections, pages, `BlockRenderer` vs `StrapiBlocks`) | [`astro-strapi-starter/SKILL.md`](./astro-strapi-starter/SKILL.md) ||
12+
| **Loader** (`generateCollections`, `populate`, `qs`, locales) | [stub + links](./astro-strapi-loader/SKILL.md) | [`.ai` in astro-strapi-loader](https://github.com/VirtusLab-Open-Source/astro-strapi-loader/tree/main/.ai) |
13+
| **StrapiBlocks** (rich text Blocks, `theme`, overrides) | [stub + links](./astro-strapi-blocks/SKILL.md) | [`.ai` in astro-strapi-blocks](https://github.com/VirtusLab-Open-Source/astro-strapi-blocks/tree/main/.ai) |
14+
| **Cursor** scoped rules | [`.cursor/rules/`](../.cursor/rules/) — loader/blocks `.mdc` are **stubs** linking upstream; starter + Tailwind/shadcn are local ||
15+
16+
**Why stubs?** The full **SKILL.md** bodies for the loader and blocks packages are maintained in their **own** repositories. This starter keeps **only** a short file per package (YAML frontmatter for skill discovery + links to the official raw Markdown) so we **do not fork** or drift from upstream prose.
17+
18+
**Agents:** If your workflow allows fetching a URL, use the **raw** links inside [`astro-strapi-loader/SKILL.md`](./astro-strapi-loader/SKILL.md) and [`astro-strapi-blocks/SKILL.md`](./astro-strapi-blocks/SKILL.md). To match a **specific npm version**, replace `main` in those URLs with a **git tag** (if published) or commit SHA that matches the release you depend on.
19+
20+
## Non-negotiables (Strapi + Astro)
21+
22+
1. **Query shape:** Build Strapi **REST** parameters as **plain JavaScript objects** (`populate`, `filters`, `sort`, etc.). The loader and ecosystem use **`qs.stringify`** for URLs—**never** hand-craft query strings, `URLSearchParams` for deep trees, or `JSON.stringify` the full query. See the [loader skill upstream](https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-loader/main/.ai/astro-strapi-loader/SKILL.md).
23+
2. **Dynamic zones:** Use `populate` with `on: { 'component.api.id': { populate: ... } }` for each component UID.
24+
3. **Blocks field:** Pass **raw** API JSON into `<StrapiBlocks data={...} />`. Do not reshape the blocks array unless the CMS is not the source of truth.
25+
4. **Env:** `STRAPI_URL`, `STRAPI_TOKEN` in `.env` (see `env.example`). Token must allow Content API reads and schema introspection used at build time (see loader documentation).
26+
27+
## This repository (conventions)
28+
29+
- **Content layer:** `src/content.config.ts``generateCollections` merges into `export const collections`. Handle Strapi being offline: `try/catch` and export static fallbacks or empty collections as the starter does.
30+
- **Strapi types:** `src/types/strapi.ts` — keep in sync with content-type shapes.
31+
- **Dynamic zone components:** `src/components/blocks/BlockRenderer.astro` dispatches `__component` to Astro block components. **Rich-text block fields** inside components use `StrapiBlocks` (e.g. `TextBlock.astro`, `HeroBlock.astro`).
32+
- **Styles:** `src/styles/global.css` — Tailwind v4 `@import 'tailwindcss'`, `@theme`, shadcn theme imports. Prefer utilities and design tokens already defined there.
33+
- **shadcn:** `components.json` + `src/components/ui/` — new primitives via the shadcn CLI; use `@/lib/utils` `cn()` for class merging.
34+
35+
## Tailwind CSS and shadcn/ui
36+
37+
- **Tailwind v4** in this repo: Vite plugin in `astro.config.mjs`, no separate `tailwind.config.js` required for the default setup. Follow [Tailwind v4](https://tailwindcss.com/docs) and keep layers in `global.css`.
38+
- **Official “agent rules”** for Tailwind from Tailwind Labs are distributed via **Tailwind Insiders** and are **not** redistributed here. Rely on public docs and the patterns in this repo.
39+
- **shadcn/ui** (registry-driven copy-paste components): see [shadcn documentation](https://ui.shadcn.com/). The [shadcn-ui/ui](https://github.com/shadcn-ui/ui) monorepo contains maintainer `.cursor` rules for **that** project; treat them as inspiration, not a drop-in, because this starter is **Astro + React islands**, not Next.js.
40+
41+
## Using skills in your editor
42+
43+
- **Agent Skills (SKILL.md):** [`.ai/astro-strapi-starter/`](./astro-strapi-starter/SKILL.md) is the only **full** starter-specific guide here. For loader and blocks, follow the **raw** URLs in the stub files or add your tool’s “fetch from URL” if supported.
44+
- **`.cursor/skills/`:** You can symlink or copy **`astro-strapi-starter/`** only. For `astro-strapi-loader` / `astro-strapi-blocks`, either paste the **raw** upstream `SKILL.md` there when a tool needs a local file, or use upstream links—do not maintain a second long-term copy in this repository.
45+
- **Cursor:** Project rules live in [`.cursor/rules/`](../.cursor/rules/). A root [`AGENTS.md`](../AGENTS.md) points to this file for discoverability.
46+
47+
## Security
48+
49+
- Do not commit secrets. Never paste real `STRAPI_TOKEN` values into skills, rules, or issues.
50+
- Treat Strapi public permissions and preview tokens with the same care as any production API credential.

.ai/astro-strapi-blocks/SKILL.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: astro-strapi-blocks
3+
description: >-
4+
@sensinum/astro-strapi-blocks: Strapi 5 Blocks field, StrapiBlocks, theme extend/overwrite,
5+
custom block overrides. Full instructions are maintained upstream; open the links below.
6+
---
7+
8+
# @sensinum/astro-strapi-blocks (reference)
9+
10+
**Do not treat this file as the manual.** The canonical **SKILL.md** and **reference.md** live in the **astro-strapi-blocks** repository.
11+
12+
| | URL |
13+
|---|-----|
14+
| **SKILL (GitHub view)** | <https://github.com/VirtusLab-Open-Source/astro-strapi-blocks/blob/main/.ai/astro-strapi-blocks/SKILL.md> |
15+
| **SKILL (raw, for tools)** | <https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-blocks/main/.ai/astro-strapi-blocks/SKILL.md> |
16+
| **Reference — theme paths (GitHub)** | <https://github.com/VirtusLab-Open-Source/astro-strapi-blocks/blob/main/.ai/astro-strapi-blocks/reference.md> |
17+
| **Reference (raw)** | <https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-blocks/main/.ai/astro-strapi-blocks/reference.md> |
18+
| **AGENTS** | <https://github.com/VirtusLab-Open-Source/astro-strapi-blocks/blob/main/.ai/AGENTS.md> |
19+
| **`.ai` tree** | <https://github.com/VirtusLab-Open-Source/astro-strapi-blocks/tree/main/.ai> |
20+
21+
This starter’s [`.ai/AGENTS.md`](../AGENTS.md) summarizes project conventions. The local [`.cursor/rules/astro-strapi-blocks.mdc`](../../.cursor/rules/astro-strapi-blocks.mdc) only sets **globs** and links to the **upstream** `.mdc` (not a duplicate of the full rule text).

.ai/astro-strapi-loader/SKILL.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: astro-strapi-loader
3+
description: >-
4+
Use @sensinum/astro-strapi-loader with Astro Content Layer: Strapi REST query objects,
5+
generateCollections, populate, qs, locales, dynamic zones. Full instructions are maintained
6+
upstream; open the links below. Strapi 5, Astro 6+.
7+
---
8+
9+
# @sensinum/astro-strapi-loader (reference)
10+
11+
**Do not treat this file as the manual.** The canonical **SKILL.md** is versioned in the **astro-strapi-loader** repository. Follow these links (pin to a **tag or commit** that matches your `package.json` version if you need strict alignment).
12+
13+
| | URL |
14+
|---|-----|
15+
| **SKILL (GitHub view)** | <https://github.com/VirtusLab-Open-Source/astro-strapi-loader/blob/main/.ai/astro-strapi-loader/SKILL.md> |
16+
| **SKILL (raw, for tools)** | <https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-loader/main/.ai/astro-strapi-loader/SKILL.md> |
17+
| **AGENTS** | <https://github.com/VirtusLab-Open-Source/astro-strapi-loader/blob/main/.ai/AGENTS.md> |
18+
| **`.ai` tree** | <https://github.com/VirtusLab-Open-Source/astro-strapi-loader/tree/main/.ai> |
19+
20+
This starter’s [`.ai/AGENTS.md`](../AGENTS.md) summarizes non‑negotiables. The local [`.cursor/rules/astro-strapi-loader.mdc`](../../.cursor/rules/astro-strapi-loader.mdc) only sets **globs** and links to the **upstream** `.mdc` (not a duplicate of the full rule text).

.ai/astro-strapi-starter/SKILL.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
name: astro-strapi-starter
3+
description: >-
4+
Develop and extend the Astro + Strapi starter: content.config with @sensinum/astro-strapi-loader,
5+
Strapi 5 data in Astro pages, StrapiBlocks for rich text Blocks fields, dynamic zone BlockRenderer,
6+
Tailwind 4 and shadcn/ui. Use when wiring Strapi collections, new block components, or
7+
CMS-driven pages using this template.
8+
---
9+
10+
# Astro × Strapi starter (VirtusLab template)
11+
12+
## Scope
13+
14+
- **Stack:** Astro 6+, Strapi 5, `@sensinum/astro-strapi-loader`, `@sensinum/astro-strapi-blocks`, Tailwind CSS 4, shadcn-style UI in `src/components/ui/`.
15+
- **Goal:** Add or change CMS-driven content, query shapes, and UI while keeping one source of truth for Strapi REST objects and a clear split between **dynamic zone components** and **rich-text Blocks**.
16+
17+
## Read next
18+
19+
- **Loader (queries, collections, locales):** stub with upstream links in [../astro-strapi-loader/SKILL.md](../astro-strapi-loader/SKILL.md) — canonical: [raw SKILL on GitHub](https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-loader/main/.ai/astro-strapi-loader/SKILL.md)
20+
- **StrapiBlocks (rich text):** stub with upstream links in [../astro-strapi-blocks/SKILL.md](../astro-strapi-blocks/SKILL.md) — canonical: [raw SKILL on GitHub](https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-blocks/main/.ai/astro-strapi-blocks/SKILL.md)
21+
- **Project overview:** [../AGENTS.md](../AGENTS.md)
22+
23+
## Configuration flow
24+
25+
1. **Environment:** `STRAPI_URL`, `STRAPI_TOKEN` in `.env` (see `env.example`). Required for a live build against Strapi; the starter can fall back if the CMS is down (see `content.config.ts` and pages).
26+
2. **Collections:** In `src/content.config.ts`, define **named query objects** (e.g. `homepageQuery`, `pagesQuery`) and pass them to `generateCollections({ url, token }, [{ name, query }, ...])`. Export merged `collections`.
27+
3. **Queries:** Reuse **fragments** (hero, SEO, shared components) with object spread. For dynamic zones, use `on` with **exact component UIDs** from the Strapi schema.
28+
4. **Pages:** Use `getCollection` / `getEntry` from `astro:content`. Single types often appear as a one-item collection—normalize with a small helper if you use `[0]`.
29+
30+
## Two rendering paths (do not confuse them)
31+
32+
| Source in Strapi | In Astro | Package / pattern |
33+
|------------------|----------|-------------------|
34+
| **Dynamic zone** (components with `__component`) | Map `__component` in a parent (e.g. `BlockRenderer.astro`) | Project components under `src/components/blocks/` |
35+
| **Rich text → “Blocks”** (editor blocks JSON) | `<StrapiBlocks data={...} />` | `@sensinum/astro-strapi-blocks` |
36+
37+
Use **StrapiBlocks** for the Strapi 5 **Blocks** rich-text field. Use **custom Astro components** for **dynamic zone** entries your schema defines (hero, CTA, etc.).
38+
39+
## StrapiBlocks in this project
40+
41+
- Import: `import { StrapiBlocks } from '@sensinum/astro-strapi-blocks'`.
42+
- Pass **unmodified** field data, e.g. from a text component’s `content` or hero copy.
43+
- Optional: `theme`, `class`, or `blocks={{ ... }}` overrides per package docs.
44+
- Centralize large `theme` objects in a module to avoid drift between pages.
45+
46+
## New dynamic zone block (example workflow)
47+
48+
1. Add the component in Strapi and note its `__component` string.
49+
2. Extend `Strapi*Component` types in `src/types/strapi.ts` if you use TypeScript strongly.
50+
3. Add a new Astro file under `src/components/blocks/` and a branch in `BlockRenderer.astro`.
51+
4. Update **populate** for the dynamic zone so the new component’s media and relations are included (see loader skill, `on` / nested `populate`).
52+
53+
## New collection or content type
54+
55+
1. Add a **query** object and a new entry in the `generateCollections` definition list.
56+
2. Add Zod/typing as needed; keep field names aligned with the API.
57+
3. Add pages under `src/pages/` that call `getCollection` with the new key.
58+
59+
## UI (Tailwind + shadcn)
60+
61+
- Global design tokens and Tailwind: `src/styles/global.css`.
62+
- React shadcn primitives: `src/components/ui/`, `cn()` from `@/lib/utils`, aliases from `components.json`.
63+
- Pure Astro + Tailwind lives alongside React islands—keep one visual language (spacing, color tokens) across both.
64+
65+
## Verification
66+
67+
- `npm run build` runs `astro check` and a production build—use after changing schemas, `content.config.ts`, or block components.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: Astro + Strapi Blocks — StrapiBlocks, data, theme (extend/overwrite), custom blocks
3+
globs: "**/*.{astro,ts,tsx}"
4+
alwaysApply: false
5+
---
6+
7+
# Upstream rule (no local copy)
8+
9+
The full **Cursor project rule** for Strapi Blocks is maintained in the **astro-strapi-blocks** repository. Open or fetch:
10+
11+
- **GitHub:** <https://github.com/VirtusLab-Open-Source/astro-strapi-blocks/blob/main/.cursor/rules/astro-strapi-blocks.mdc>
12+
- **Raw:** <https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-blocks/main/.cursor/rules/astro-strapi-blocks.mdc>
13+
14+
This file exists only to **preserve** the same `globs` / scope in this starter. For project-specific notes, see [`.ai/AGENTS.md`](../../.ai/AGENTS.md) and the stub at [`.ai/astro-strapi-blocks/SKILL.md`](../../.ai/astro-strapi-blocks/SKILL.md).
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
description: Strapi 5 + @sensinum/astro-strapi-loader — content.config.ts, populate, qs, locales
3+
globs: "**/content.config.ts"
4+
alwaysApply: false
5+
---
6+
7+
# Upstream rule (no local copy)
8+
9+
The full **Cursor project rule** for the loader is maintained in the **astro-strapi-loader** repository. Open or fetch:
10+
11+
- **GitHub:** <https://github.com/VirtusLab-Open-Source/astro-strapi-loader/blob/main/.cursor/rules/astro-strapi-loader.mdc>
12+
- **Raw:** <https://raw.githubusercontent.com/VirtusLab-Open-Source/astro-strapi-loader/main/.cursor/rules/astro-strapi-loader.mdc>
13+
14+
This file exists only to **preserve** the same `globs` / scope in this starter. For project-specific notes, see [`.ai/AGENTS.md`](../../.ai/AGENTS.md) and the stub at [`.ai/astro-strapi-loader/SKILL.md`](../../.ai/astro-strapi-loader/SKILL.md).
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
description: Astro x Strapi starter — layout, content collections, block renderer vs StrapiBlocks, types
3+
globs: "**/src/**"
4+
alwaysApply: false
5+
---
6+
7+
# Astro Strapi starter
8+
9+
- **Stack:** Astro 6, Strapi 5, `@sensinum/astro-strapi-loader`, `@sensinum/astro-strapi-blocks` (read [`.ai/AGENTS.md`](../../.ai/AGENTS.md) and [`.ai/astro-strapi-starter/SKILL.md`](../../.ai/astro-strapi-starter/SKILL.md)).
10+
11+
- **Content:** `src/content.config.ts` exports `collections` from `generateCollections`. Handle Strapi unavailability in `try/catch` so static builds or local dev can still run.
12+
13+
- **Two patterns:** (1) **Dynamic zone** entries with `__component` → `BlockRenderer.astro` and siblings under `src/components/blocks/`. (2) **Rich text Blocks JSON** from Strapi 5 → `<StrapiBlocks />` inside those components when the field is a Blocks editor, not a separate dynamic-zone component.
14+
15+
- **Types:** Keep `src/types/strapi.ts` aligned with the Strapi content types; extend when adding new components.
16+
17+
- **Do not** commit `.env` or real API tokens. Use `env.example` as the template for variable names.

.cursor/rules/tailwind-shadcn.mdc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
description: Tailwind CSS 4 + shadcn-style UI — global.css, components.json, cn(), Astro + React
3+
globs: "**/src/styles/**/*.css,**/components.json,**/src/components/ui/**,**/src/lib/utils.ts"
4+
alwaysApply: false
5+
---
6+
7+
# Tailwind CSS 4 and shadcn-style components (this starter)
8+
9+
- **Tailwind v4** is applied via `@tailwindcss/vite` in `astro.config.mjs`. Global entry: `src/styles/global.css` with `@import 'tailwindcss'`, `@theme`, and shadcn theme imports. Prefer **utilities** and existing **CSS variables** from that file; extend tokens in `@theme` when adding project-wide design changes.
10+
11+
- **Shadcn-style React components** live in `src/components/ui/` and are generated from [shadcn/ui](https://ui.shadcn.com/) using `components.json` (New York style, `src/styles/global.css`). Use the shadcn CLI to add or update components; do not hand-copy unrelated project snippets.
12+
13+
- **Class merging** for React: use `cn()` from `@/lib/utils` (clsx + tailwind-merge). For Astro, use regular `class` strings or `clsx` where the starter already does.
14+
15+
- **Astro + Tailwind** showcase components and **React** shadcn elements coexist; keep **spacing, color, and radius** consistent with the design tokens in `global.css` so the UI looks unified.
16+
17+
- This repo does **not** include proprietary Tailwind Insiders “agent rules.” Follow public [Tailwind v4 documentation](https://tailwindcss.com/docs) and the patterns already in the codebase.

.yarnrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
4+
15
nodeLinker: node-modules

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AI agent context
2+
3+
Full instructions for this repository live in **[`.ai/AGENTS.md`](.ai/AGENTS.md)**. Package-specific **loader** and **blocks** skills are **not** vendored: stubs under `.ai/` link to the canonical files on GitHub; only the **starter** skill is written in full here.
4+
5+
If your tool only reads the repository root, open that file; skills and references are under [`.ai/`](.ai/).

0 commit comments

Comments
 (0)