@@ -11,26 +11,168 @@ This is an Astro-based static site generator project using TypeScript, Preact, a
1111- ** Astro** : Static site generator with component-based architecture
1212- ** TypeScript** : Strict mode enabled, prefer explicit typing
1313- ** Preact** : Use functional components with hooks for client-side interactivity
14- - ** Bun** : Runtime and package manager, ES modules preferred
15- - ** Package Manager** : Use Bun (bun.lockb present)
14+ - ** npm** : Package manager (use ` npm ` for all installs and scripts)
1615
17- ## Critical Bun & Astro Rules
16+ ## Critical npm & Astro Rules
1817
19- ### Bun Commands Only
18+ ### npm Commands Only
2019
21- - Use Bun exclusively: ` bun run ` , ` bun test ` , ` bun install ` , ` bun add ` , ` bun remove `
22- - Never use ` node ` , ` npm ` , ` yarn ` , ` pnpm ` commands
23- - Use ` bun --filter ` for workspace operations: ` bun --filter="./src/packages/*" run build `
24- - Leverage Bun's built-in test runner (no Jest, Vitest, or other test frameworks)
25- - Use Bun's native TypeScript support (no ts-node or similar)
20+ - Use npm exclusively: ` npm run ` , ` npm test ` , ` npm install ` , ` npm uninstall `
21+ - Never use ` bun ` , ` yarn ` , or ` pnpm ` commands
22+ - Use ` npm install ` for dependencies, ` npm install --save-dev ` for dev dependencies
23+ - Use ` npx ` to run one-off executables (e.g. ` npx astro check ` )
2624
2725### Common Astro Commands
2826
29- - ** Development** : ` bun dev ` or ` bun start ` - Start Astro dev server
30- - ** Build** : ` bun build ` - Build static site for production
31- - ** Preview** : ` bun preview ` - Preview production build locally
32- - ** Type Check** : ` bun astro check ` - Run Astro's built-in type checker
33- - ** Generate Types** : ` bun astro sync ` - Generate TypeScript definitions
27+ - ** Development** : ` npm run dev ` — Start Astro dev server
28+ - ** Build** : ` npm run build ` — Build static site for production
29+ - ** Preview** : ` npm run preview ` — Preview production build locally
30+ - ** Type Check** : ` npm run check ` — Run Astro's built-in type checker
31+ - ** Generate Types** : ` npx astro sync ` — Generate TypeScript definitions
32+
33+ ### Build & Development Tools
34+
35+ - ** Astro** : Static site generator with component islands architecture
36+ - ** Vite** : Underlying build tool (managed by Astro)
37+ - ** ESLint** : Code linting with strict rules
38+ - ** Prettier** : Code formatting (check .prettierrc for config)
39+ - ** TypeScript** : Strict configuration in tsconfig.json
40+
41+ ### Testing
42+
43+ - Follow existing test patterns if tests are present
44+ - Prefer unit tests for utilities, integration tests for components
45+
46+ ## Code Style & Standards
47+
48+ ### TypeScript Guidelines
49+
50+ - Use strict mode settings from tsconfig.json
51+ - Prefer explicit return types for functions
52+ - Use proper type annotations, avoid ` any `
53+ - Leverage union types and type guards
54+ - Use interfaces for object shapes, types for unions/primitives
55+
56+ ### Preact Guidelines
57+
58+ - Use functional components with hooks
59+ - Prefer arrow functions for components
60+ - Use proper TypeScript typing for props and state
61+ - Follow React best practices for performance (useMemo, useCallback when needed)
62+ - Use proper dependency arrays in useEffect
63+
64+ ### File Organization
65+
66+ - ** Astro Pages** : ` /src/pages/ ` - File-based routing, supports .astro, .md, .mdx, .html files
67+ - ** Astro Components** : ` /src/components/ ` - Reusable .astro components
68+ - ** Astro Layouts** : ` /src/layouts/ ` - Page layout components
69+ - ** Client Components** : ` /src/components/ ` - Preact components for client-side interactivity
70+ - ** Assets** : ` /src/assets/ ` - Images, fonts, and other static assets
71+ - ** Styles** : ` /src/styles/ ` - CSS, SCSS, or style files
72+ - ** Utilities** : ` /src/lib/ ` or ` /src/utils/ ` - Shared TypeScript utilities
73+ - ** Content** : ` /src/content/ ` - Markdown content with collections (if using content collections)
74+ - ** Public** : ` /public/ ` - Static assets served directly
75+ - Follow the existing directory structure
76+ - Group related files together
77+ - Use index files for clean imports
78+ - Prefer named exports over default exports for utilities
79+
80+ ## Astro-Specific Guidelines
81+
82+ ### Component Types
83+
84+ - ** Astro Components (.astro)** : For static content, server-side rendering, and layouts
85+ - ** Client Components (Preact)** : Use ` client:* ` directives for interactivity
86+ - ** Hybrid Components** : Astro components that import and use client components
87+
88+ ### Client Directives
89+
90+ - ` client:load ` - Hydrate immediately on page load
91+ - ` client:idle ` - Hydrate when main thread is idle
92+ - ` client:visible ` - Hydrate when component enters viewport
93+ - ` client:media ` - Hydrate when media query matches
94+ - ` client:only ` - Skip server rendering, only run on client
95+
96+ ### Content Collections (if used)
97+
98+ - Define schemas in ` src/content/config.ts `
99+ - Use ` getCollection() ` and ` getEntry() ` for content queries
100+ - Leverage TypeScript types generated from schemas
101+
102+ ### Code Quality
103+
104+ - Follow ESLint rules strictly
105+ - Use Prettier for consistent formatting
106+ - Write self-documenting code with clear variable names
107+ - Add JSDoc comments for complex functions
108+ - Prefer composition over inheritance
109+
110+ ## Development Workflow
111+
112+ ### Dependencies
113+
114+ - Check package.json for existing dependencies before adding new ones
115+ - Use exact versions for critical dependencies
116+ - Keep dependencies up to date but test thoroughly
117+
118+ ### Environment
119+
120+ - Use environment variables for configuration
121+ - Follow existing patterns for env variable usage
122+ - Keep sensitive data out of the codebase
123+
124+ ### Git & Commits
125+
126+ - Write clear, descriptive commit messages
127+ - Follow conventional commit format if established
128+ - Keep commits focused and atomic
129+
130+ ## Specific Preferences
131+
132+ ### Import/Export Style
133+
134+ - Use ES6 import/export syntax
135+ - Organize imports: external libraries first, then internal modules
136+ - Use absolute imports if configured in tsconfig paths
137+
138+ ### Error Handling
139+
140+ - Use proper error boundaries in React
141+ - Implement comprehensive error handling in async operations
142+ - Prefer specific error types over generic Error
143+
144+ ### Performance Considerations
145+
146+ - Consider bundle size when adding dependencies
147+ - Use code splitting for large components/features
148+ - Optimize re-renders with proper memoization
149+
150+ ### Accessibility
151+
152+ - Follow WCAG guidelines
153+ - Use semantic HTML elements
154+ - Include proper ARIA attributes when needed
155+ - Ensure keyboard navigation works
156+
157+ ## Files to Reference
158+
159+ - ` tsconfig.json ` - TypeScript configuration
160+ - ` astro.config.mjs ` - Astro configuration and integrations
161+ - ` package.json ` - Dependencies and scripts
162+ - ` .eslintrc.* ` - Linting rules
163+ - ` .prettierrc ` - Formatting rules
164+
165+ ## Common Patterns
166+
167+ When suggesting code changes:
168+
169+ 1 . Check existing patterns in the codebase first
170+ 2 . Maintain consistency with current architecture
171+ 3 . Consider the impact on bundle size and performance
172+ 4 . Ensure type safety throughout
173+ 5 . Follow the established error handling patterns
174+ 6 . Maintain the current level of code documentation
175+
34176
35177### Build & Development Tools
36178
0 commit comments