mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 12:05:28 +00:00
2.9 KiB
2.9 KiB
AGENTS Guidelines
- Install: pnpm i (Node via .nvmrc / .tool-versions). Dev: pnpm dev. Build: pnpm build. Preview: pnpm preview. No test suite defined (add if needed); run single script via pnpm <script>.
- Lint: npx eslint . (autoset by lint-staged). Format: npx prettier --write . Pre-commit runs lint-staged -> prettier then eslint fix per .lintstagedrc.json.
- Tech: Astro + React + TS, Tailwind, MDX. Use ESM ("type":"module"). Prefer .astro for pages/layouts; isolated React (.tsx) only when interactivity or charts needed.
- Imports: Rely on Prettier organize-imports & tailwind plugin; no manual sorting. Group: std libs, external deps, internal (absolute/relative). Omit file extensions except for non-code assets. Avoid deep relative chains; create utility barrels if scaling (>3 siblings).
- Formatting: Prettier enforced; tabs (width 4) except MD/MDX/YAML (2 spaces). Single quotes in code, double in MD/YAML. 100 char print width. Trailing commas es5. LF endings.
- Types: Strict TS (see tsconfig). Always type exported function params/return if not inferred. Use readonly, const assertions, narrow early. Prefer union types + discriminants over enums unless exhaustive mapping.
- Components: PascalCase for React/Astro components; files match component. One default export per component file. Hooks (if added) camelCase prefixed use.
- Variables/functions: camelCase, const by default. UPPER_CASE only for true constants. Avoid Hungarian notation.
- Content collections: Use defined schemas in src/schema/* for validation; extend there rather than ad hoc field access. Central site/meta config in data/site.ts.
- CSS: Tailwind utility-first; extract repeated patterns via @apply in scoped layer components or create small Astro components.
- Errors: Fail fast; throw Error with descriptive message; no silent catch. Wrap external IO (fs/network) with try/catch and rethrow enriched context.
- Date/time: Use utils/date.ts helpers. Avoid new Date(...) formatting inline.
- Performance: Prefer static generation; use React only when necessary. Avoid moment for new code (consider Intl APIs) but keep legacy until refactor.
- Images: Use provided conversion scripts (pnpm webp, og:generate, icons:generate). Do not commit large unoptimized assets.
- Accessibility: Use semantic HTML in Astro; add alt text; a11y lint via eslint-plugin-jsx-a11y (applies to .tsx portions).
- Markdown/MDX: Frontmatter validated; writing style not enforced here; keep line length flexible (formatter handles wrapping).
- Commit hygiene: Small, focused commits; pre-commit will block formatting issues. Run full lint before large refactors.
- Adding posts: Use plop (pnpm plop) generators where available instead of manual copy to ensure schema alignment.
- Secrets: Do not hardcode keys; if env vars needed add to env.d.ts and .env (not committed) and reference import.meta.env.
- Automation: Husky pre-commit + lint-staged only; extend by adding new hooks if necessary (keep fast <5s).