Commit a1863910 by PLN (Algolia)

chore: cline rules+yarn

parent c97122fc
---
description: Keep Markdown content in next/content and static assets in next/public with predictable paths
globs:
alwaysApply: true
---
# Content location (Markdown/MDX)
- Store all site content in `next/content/**` (e.g., posts, poems, talks, hydras, lives).
- Do not scatter Markdown/MDX outside `next/content/**`.
- When adding new sections, create a folder under `next/content/SECTION_NAME`.
# Static assets (images, gifs, icons, files)
- Place all static assets under `next/public/**`.
- Reference assets with absolute paths (e.g., `/images/...`) rather than relative filesystem paths.
- Prefer `next/image` where applicable for image optimization; fall back to `<img>` when necessary.
# Hotlinking
- Avoid hotlinking for persistent assets (images/gifs used in content or UI). Copy them into `next/public/**`.
# Organization conventions
- Use `next/public/images/SECTION/...` for section-specific assets (e.g., `parvagues`, `hydras`, `lives`, `posts`).
- Keep large/rarely used files out of git history when possible (use external storage/CDN), but link them in content.
# Build/deploy stability
- Do not fetch remote static assets at build time for core UI; ensure assets are present in `next/public/**`.
- Keep filenames stable to avoid cache-busting issues unless intentionally versioning assets.
---
description: Enforce environment variable handling and secrets hygiene with Vercel
globs:
alwaysApply: true
---
# Environment & secrets policy
- Do not commit `.env*` files to the repo (e.g. `.env`, `.env.local`, `.env.production`, `.env.development`).
- Manage secrets in Vercel Environment Variables (Production / Preview).
- Never hardcode API keys, tokens, or secrets in code, content, or markdown.
# Local development (Yarn + Vercel)
- Link the project and pull envs locally from `next/`:
- `yarn preview:link` (or `vercel link --yes`)
- `yarn preview:env:pull` (or `vercel env pull .env.local`)
- Only read environment variables via `process.env.*` at runtime or in build as appropriate.
# Next.js env conventions
- Use `NEXT_PUBLIC_*` prefix only for variables that are safe to expose to the browser.
- Server-only secrets must NOT be prefixed with `NEXT_PUBLIC_` and should only be used on server-side code paths (e.g. getServerSideProps, API routes).
# Vercel environments
- Keep distinct values per environment (Production vs Preview) in Vercel settings.
- Validate Preview behavior via a Vercel Preview URL before promoting to Production.
---
description:
globs:
description: Enforce @/ alias usage for imports in Next.js app
globs:
alwaysApply: true
---
# Use @/ syntax for imports in Next.js projects
- Always use `@/components/xxx` syntax, not the `../../components/xxx` syntax.
\ No newline at end of file
- Always use `@/components/...`, `@/lib/...`, etc. Avoid long `../../` relative paths.
- Keep the webpack alias mapping `@ → next/` intact in `next/next.config.js`.
- When moving files, update imports to continue using the `@/` alias.
---
description: Enforce Next.js app root, directory layout, and command locations
globs:
alwaysApply: true
---
# App root and command execution
- The Next.js app root is `next/`. Do not move the app to the repository root or create additional app roots.
- Run all app commands from `next/` (or use `--cwd next` if invoking from repo root):
- `yarn dev`, `yarn build`, `yarn start`
- `vercel`, `vercel --prod`, `vercel build`
# Directory layout conventions
- Pages and routes live in `next/pages/**`.
- Reusable UI in `next/components/**`.
- Utility code in `next/lib/**`.
- Global and module styles in `next/styles/**` (only import global CSS from `pages/_app.js`).
- Static assets in `next/public/**` referenced with absolute paths like `/images/...`.
- Markdown/MDX content in `next/content/**` (do not scatter content elsewhere).
# Path alias
- Keep webpack alias `@` → `next/` in `next/next.config.js`.
- Prefer imports like `@/components/Button` over deep relative paths.
# Build/deploy stability
- Do not introduce separate Next.js app roots or change the root in Vercel settings (must be `next/`).
- Avoid build-time network fetches for core UI assets; ensure they live in `next/public/**`.
---
description:
globs: *.css
alwaysApply: false
description: Enforce Next.js global CSS rule — only import global CSS from pages/_app.js
globs:
alwaysApply: true
---
# AVoid global css:
Global CSS cannot be imported from files other than your Custom <App>. Due to the Global nature of stylesheets, and to avoid conflicts, Please move all first-party global CSS imports to pages/_app.js. Or convert the import to Component-Level CSS (CSS Modules).
# Avoid global CSS outside Custom App
- Global CSS must only be imported from `next/pages/_app.js`.
- Do not import global styles from other pages or components.
- Prefer CSS Modules or component-scoped CSS for local styles.
# Rationale
- Next.js enforces a single global stylesheet entrypoint to avoid style conflicts and runtime errors.
- This keeps styles isolated and reduces regressions for new devs.
# Allowed imports in _app.js (example)
- `import 'bootstrap/dist/css/bootstrap.css'`
- `import '@/styles/globals.css'`
- `import '@/styles/main.css'`
- `import '@/styles/masonry.css'`
---
description: Enforce Yarn (classic) as the only package manager and prevent lockfile drift
globs:
alwaysApply: true
---
# Yarn-only policy
- Use Yarn (classic) exclusively for installs and scripts.
- Keep `yarn.lock` as the single source of truth.
# Disallow other lockfiles
- Do not add or commit `package-lock.json`, `pnpm-lock.yaml`, or any other lockfile.
- If such files appear (e.g., in `next/` or repo root), remove them to avoid engine/lockfile drift.
# Deterministic installs
- Install with: `yarn install --frozen-lockfile`
- In CI and Vercel, rely on Yarn. Do not invoke npm or pnpm.
# Scripts
- Run all app scripts from `next/` (or use `--cwd next`), e.g.:
- `yarn dev`
- `yarn build`
- `yarn start`
- `yarn deploy:preview` / `yarn deploy:prod` (if defined)
---
description: Project-wide standards to keep Next.js app stable, Yarn-only, and Vercel deploys safe
globs:
alwaysApply: true
---
# Node & runtime
- Use Node 20 LTS (recommended) or at minimum >= 18.18 to satisfy Next.js 15.
- Align .nvmrc with package.json "engines" (prefer `20.x`). Do not downgrade Node.
- In Vercel, set Node 20 runtime (Project Settings > Build & Development Settings).
# Package manager — Yarn only
- Use Yarn (classic) exclusively; keep `yarn.lock` as the single source of truth.
- Do not add or commit `package-lock.json`, `pnpm-lock.yaml`, or any other lockfile.
- Install deterministically with: `yarn install --frozen-lockfile`.
- In CI/Vercel, rely on Yarn workflows; do not invoke npm or pnpm.
# Next.js project structure
- The app root is fixed at `next/`. Run all app commands from `next/` (or use `--cwd next`).
- Do not move the app to repository root or create additional app roots.
- Keep the webpack alias mapping `@ → next/` intact in `next/next.config.js`.
# Imports alias
- Prefer `@/xxx` imports (e.g., `@/components/Button`) instead of deep `../../` relative paths.
- When moving files, update imports to keep using `@/`.
# Global CSS policy
- Only import global CSS from `next/pages/_app.js`.
- Convert all other styles to CSS Modules or component-scoped CSS.
- Do not add new global CSS imports in pages/components.
- Note: This complements the existing rule in `.cursor/rules/no-global-css.mdc`.
# Content and static assets
- Markdown/MDX content lives under `next/content/**`.
- Static assets belong in `next/public/**` and should be referenced with `/...` paths.
- Avoid hotlinking for persistent assets; store them in `next/public`.
# Environment & secrets
- Do not commit `.env*` files. Manage secrets in Vercel Environment Variables (Production / Preview).
- For local development, sync envs from Vercel: `vercel env pull .env.local` (via local CLI).
- Never hardcode secrets or tokens in code or content.
# Vercel deploy policy (Preview-first)
- Default to Preview deploys for every branch:
- From `next/`: `vercel` (or `yarn vercel` if CLI is a devDependency).
- Share the Preview URL in PRs for review.
- Promote to Production only after approval:
- From `main` branch: `vercel --prod` (or `yarn vercel --prod`).
- Ensure Vercel Project “Root Directory” is set to `next/`.
- Use `vercel build` locally to reproduce platform builds when debugging.
# Scripts & CI conventions (Yarn)
- Local dev: run from `next/` → `yarn dev`
- Build locally/CI: from `next/` → `yarn build`
- Deterministic install: `yarn install --frozen-lockfile`
- Optional (recommended) devDependencies/scripts in `next/package.json` to keep Yarn-only workflow:
- Add devDependency: `"vercel": "^39"` (or current)
- Scripts:
- `"preview:link": "vercel link --yes"`
- `"preview:env:pull": "vercel env pull .env.local"`
- `"deploy:preview": "vercel --yes"`
- `"deploy:prod": "vercel --prod --yes"`
- `"platform:build": "vercel build"`
- Then use: `yarn preview:env:pull`, `yarn deploy:preview`, etc.
- Do not introduce npm-based CI steps (`npm ci`, `npx`, etc.) in this repo.
# PR & release guardrails
- All PRs must include a working Vercel Preview URL for reviewers.
- Do not merge if Preview build fails or diverges from local due to engine/lockfile drift.
- Production deploys happen via `vercel --prod` after merge to `main` and review.
# Quick checklist for new devs
- `nvm use 20`
- `cd next && yarn install --frozen-lockfile`
- `yarn dev`
- (optional first time) `yarn preview:link` then `yarn preview:env:pull`
- `yarn deploy:preview` to share a link before `yarn deploy:prod`
---
description: Enforce Vercel preview-first deploy policy with Yarn-only workflow
globs:
alwaysApply: true
---
# Vercel deploy policy (Preview-first)
- Always create a Preview deployment before Production.
- Run all Vercel CLI commands from `next/` (or use `--cwd next` if invoking from repo root).
- Ensure Vercel Project “Root Directory” is set to `next/` in Vercel settings.
# Commands (Yarn-only)
- Preview (default): `vercel` (or `yarn vercel` if CLI is a devDependency)
- Promote to Production (after approval): `vercel --prod` (or `yarn vercel --prod`)
- Link project: `vercel link --yes`
- Sync envs locally: `vercel env pull .env.local`
- Reproduce platform build locally: `vercel build`
# Guardrails
- Do not run `--prod` from feature branches.
- Include the Preview URL in PR description for review.
- Do not merge if Preview build fails or diverges from local due to engine/lockfile drift.
# Node & runtime
- Use Node 20.x runtime in Vercel.
- Local devs use `nvm use 20` before running Yarn commands.
# Yarn-only install in CI/Vercel
- Use `yarn install --frozen-lockfile`
- Do not invoke npm or pnpm in this repo.
node_modules/
.vercel
# Env files (managed via Vercel, never commit)
.env
.env.local
.env.development
.env.production
.env.test
.env.*.local
# Yarn-only policy: ignore other lockfiles
package-lock.json
pnpm-lock.yaml
npm-shrinkwrap.json
# OS/editor noise
.DS_Store
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -5,7 +5,12 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
"start": "next start",
"preview:link": "vercel link --yes",
"preview:env:pull": "vercel env pull .env.local",
"deploy:preview": "vercel --yes",
"deploy:prod": "vercel --prod --yes",
"platform:build": "vercel build"
},
"engines": {
"node": ">=18.17.0"
......@@ -34,6 +39,7 @@
},
"devDependencies": {
"@types/react": "^18.2.61",
"typescript": "^5.3.3"
"typescript": "^5.3.3",
"vercel": "^39"
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment