From 86a9dc2d314fb88e0eb7d19ad51451a8d53784f8 Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Sat, 10 Jan 2026 11:10:51 +0000 Subject: [PATCH] docs: add AGENTS.md for agent guidelines --- AGENTS.md | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..b81018a --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,153 @@ +# Agent Guidelines for this Repository + +> **Important**: This file is the source of truth for all agents working in this repository. If you modify the build process, add new tools, change the architecture, or introduce new conventions, **you must update this file** to reflect those changes. + +## 1. Project Overview & Commands + +This is an **Astro** project using **pnpm**. + +### Build & Run Commands +- **Install Dependencies**: `pnpm install` +- **Development Server**: `pnpm dev` +- **Build for Production**: `pnpm build` (Output: `dist/`) +- **Preview Production Build**: `pnpm preview` +- **Check Types**: `npx tsc --noEmit` (since `strict` is enabled) + +### Testing & Linting +- **Linting**: No explicit lint command found in `package.json`. Follow existing code style strictly. +- **Testing**: No explicit test framework (Jest/Vitest) is currently configured. + - *If asked to add tests*: Verify if a test runner needs to be installed first. + +## 2. Directory Structure + +```text +/ +├── public/ # Static assets +├── src/ +│ ├── assets/ # Source assets (processed by Astro) +│ ├── components/ # Astro components +│ │ ├── base/ # UI Primitives +│ │ └── page/ # Layout-specific components (Header, Footer) +│ ├── content/ # Markdown/MDX content collections +│ │ ├── posts/ +│ │ ├── experiences/ +│ │ └── skills/ +│ ├── data/ # Data access layer (Classes & Utilities) +│ ├── layouts/ # Page layouts (if any) +│ ├── pages/ # File-based routing +│ ├── styles/ # Global styles (if any) +│ └── utils/ # Helper functions +├── astro.config.ts # Astro configuration +├── package.json # Dependencies & Scripts +└── tsconfig.json # TypeScript configuration +``` + +## 3. Code Style & Conventions + +### General Formatting +- **Indentation**: 2 spaces. +- **Semicolons**: **Preferred**. While mixed in some older files, new code should use semicolons. +- **Quotes**: + - **Code**: Single quotes `'string'`. + - **Imports**: Double quotes `"package"` or single quotes `'./file'` (mixed, generally follow file context). + - **JSX/Attributes**: Double quotes ``. +- **Line Endings**: LF. + +### TypeScript & JavaScript +- **Strictness**: `strictNullChecks` is enabled via `astro/tsconfigs/strict`. +- **Path Aliases**: + - Use `~/` to refer to `src/` (e.g., `import { data } from '~/data/data'`). +- **Naming**: + - Components/Classes: `PascalCase` (e.g., `Header.astro`, `Posts`). + - Variables/Functions: `camelCase` (e.g., `getPublished`). + - Constants: `camelCase` or `UPPER_CASE`. + - Private Fields: Use JS private fields `#field` over TypeScript `private` keyword where possible. +- **Error Handling**: Use `try...catch` or explicit checks (e.g., `if (!entry) throw new Error(...)`). + +### Astro Components (.astro) +- **Structure**: + ```astro + --- + // Imports + import { Picture } from "astro:assets"; + import { data } from "~/data/data"; + + // Logic (Top-level await supported) + const { title } = Astro.props; + const posts = await data.posts.getPublished(); + --- + +
+

{title}

+ {posts.map(post => {post.data.title})} +
+ + + ``` +- **Images**: Use `` from `astro:assets` for optimized images. +- **CSS**: + - Use scoped `