|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to AI coding assistants when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Official website for the book "Node.js Design Patterns" by Mario Casciaro and Luciano Mammino. Built with Astro as a minimal static site, deployed to GitHub Pages at https://nodejsdesignpatterns.com. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +pnpm dev # Start dev server at localhost:4321 |
| 13 | +pnpm build # Build production site to ./dist/ |
| 14 | +pnpm preview # Preview production build locally |
| 15 | +pnpm lint # Run ESLint |
| 16 | +pnpm lint:fix # Fix auto-fixable ESLint issues |
| 17 | +pnpm format # Format with Prettier |
| 18 | +pnpm format:check # Check formatting |
| 19 | +pnpm typecheck # TypeScript type checking |
| 20 | +``` |
| 21 | + |
| 22 | +## Architecture |
| 23 | + |
| 24 | +### Core Stack |
| 25 | + |
| 26 | +- **Astro 5** - Static site generator (ESM, TypeScript) |
| 27 | +- **Tailwind CSS 4** - Styling via Vite plugin |
| 28 | +- **React** - Used sparingly for interactive components only |
| 29 | +- **pnpm** - Package manager |
| 30 | + |
| 31 | +### Content Collections (`src/content/`) |
| 32 | + |
| 33 | +Strongly typed via Zod schemas in `src/content.config.ts`: |
| 34 | + |
| 35 | +- `authors/` - Author JSON files with profile pics |
| 36 | +- `blog/` - Blog posts (markdown with frontmatter, each in its own folder) |
| 37 | +- `chapters/` - Book chapter descriptions |
| 38 | +- `faq/` - FAQ entries |
| 39 | +- `quotes/` - Testimonials |
| 40 | +- `reviews/` - Book reviews |
| 41 | + |
| 42 | +### Key Directories |
| 43 | + |
| 44 | +- `src/components/` - Astro components (`.astro`) and React components (`.tsx`) |
| 45 | +- `src/components/blog/` - Blog-specific components including `BlogLayout.astro` |
| 46 | +- `src/components/ui/` - Reusable UI components (badge, button, card) |
| 47 | +- `src/pages/` - Astro routes (index, blog, RSS, 404) |
| 48 | +- `src/plugins/` - Remark plugins (admonitions for tip/note/warning/etc.) |
| 49 | +- `src/lib/` - Utilities, constants, theme configuration |
| 50 | +- `src/images/` - Images optimized by Astro |
| 51 | + |
| 52 | +### Markdown Features |
| 53 | + |
| 54 | +Blog posts support admonitions via remark-directive: |
| 55 | + |
| 56 | +```markdown |
| 57 | +:::tip[Custom Title] |
| 58 | +Content here |
| 59 | +::: |
| 60 | +``` |
| 61 | + |
| 62 | +Types: `tip`, `note`, `important`, `caution`, `warning` |
| 63 | + |
| 64 | +## Development Principles |
| 65 | + |
| 66 | +1. **Astro-first**: Prefer Astro components over React. Use React only for interactive features that require client-side JS. |
| 67 | + |
| 68 | +2. **Mobile-first responsive**: Use Tailwind breakpoint prefixes (`sm:`, `md:`, `lg:`) starting from mobile layouts. |
| 69 | + |
| 70 | +3. **Accessibility required**: Semantic HTML, proper heading hierarchy, ARIA labels, keyboard navigation, WCAG AA contrast. |
| 71 | + |
| 72 | +4. **Data-driven content**: Separate data from templates. Use content collections with Zod schemas. |
| 73 | + |
| 74 | +5. **Lean and fast**: Optimize images, minimize JS, pre-build everything possible. |
| 75 | + |
| 76 | +## Spec-Driven Development Workflow |
| 77 | + |
| 78 | +This project uses a spec-driven development workflow: |
| 79 | + |
| 80 | +1. **Specify** - Create feature branch and specification |
| 81 | +2. **Plan** - Generate implementation plan from spec |
| 82 | +3. **Tasks** - Break plan into executable tasks |
| 83 | + |
| 84 | +Templates are in `templates/` and helper scripts in `scripts/`. |
| 85 | + |
| 86 | +## Blog Article Creation |
| 87 | + |
| 88 | +New blog articles should: |
| 89 | + |
| 90 | +- Follow the template in `.claude/article-brief-template.md` |
| 91 | +- Use modern ESM syntax and async/await |
| 92 | +- Include FAQ section for schema markup |
| 93 | +- Place each article in its own folder under `src/content/blog/<slug>/` |
| 94 | + |
| 95 | +### Content Writing Style |
| 96 | + |
| 97 | +When writing or editing content, follow these guidelines: |
| 98 | + |
| 99 | +**Tone and Readability** |
| 100 | + |
| 101 | +- Use a friendly, approachable tone, almost colloquial, as if explaining to a colleague |
| 102 | +- Write conversationally while maintaining technical accuracy |
| 103 | +- Avoid overly formal or academic language |
| 104 | + |
| 105 | +**Punctuation** |
| 106 | + |
| 107 | +- Never use em dashes (—). Use commas, parentheses, or separate sentences instead |
| 108 | + |
| 109 | +**Structure and Flow** |
| 110 | + |
| 111 | +- Always provide context first: explain "what" and "why" before diving into "how" |
| 112 | +- Emphasize the "why": readers should understand not just how something works, but why it matters |
| 113 | +- Connect sections smoothly using: |
| 114 | + - Forward references: "In the next section, we'll see how to handle errors" |
| 115 | + - Backward references: "As we saw earlier, streams provide memory efficiency" |
| 116 | + - Previews: "Before we implement this, let's understand the underlying concept" |
| 117 | + |
| 118 | +**Technical Explanations** |
| 119 | + |
| 120 | +- Start with the problem or use case before the solution |
| 121 | +- Explain progressively: simple version first, then edge cases |
| 122 | +- Use real-world analogies for abstract concepts |
0 commit comments