-
Notifications
You must be signed in to change notification settings - Fork 1
Add CLAUDE.md with codebase guidance for AI assistants #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shazzar00ni
wants to merge
3
commits into
main
Choose a base branch
from
claude/add-claude-documentation-YvkfD
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| npm run dev # Dev server at http://localhost:3000 | ||
| npm run build # Production build → dist/ | ||
| npm run preview # Serve the production build locally | ||
| npm run lint # ESLint, fails on any warning (--max-warnings 0) | ||
| npm run lint:fix # ESLint with auto-fix | ||
| npm run format # Prettier write | ||
| npm run typecheck # tsc --noEmit (TypeScript check without emitting) | ||
| npm run test # Vitest in watch mode | ||
| npm run test:run # Vitest single run (use before committing) | ||
| npm run e2e # Playwright end-to-end tests (requires a running dev server) | ||
| ``` | ||
|
|
||
| To run a single unit test file: `npx vitest run src/components/FAQ.test.tsx` | ||
|
|
||
| Pre-commit hook runs `lint-staged`: ESLint --fix + Prettier --write on staged `.ts`/`.tsx`/`.js`/`.jsx` files. | ||
|
|
||
| ## Architecture | ||
|
|
||
| DocuGen is a **single-page marketing/landing site** (no client-side router). Navigation is anchor-based (`#features`, `#pricing`, etc.). The app has no backend; all content is static. | ||
|
|
||
| ### Application entry | ||
|
|
||
| `main.tsx` mounts `<App>` inside `<React.StrictMode>`. `App.tsx` owns the `<ThemeProvider>` wrapper and renders the full page as a vertical stack of sections. | ||
|
|
||
| Above-fold sections (`Hero`, `HowItWorks`, `FAQ`) are eagerly imported. Below-fold sections (`Features`, `Testimonials`, `Preview`, `Pricing`, `Newsletter`) use `React.lazy` + `<Suspense>` for code splitting. | ||
|
|
||
| ### Content layer | ||
|
|
||
| Copy should live in `src/data/content.ts`, which exports named constants (`HERO_COPY`, `FEATURES`, `FAQS`, `PRICING_COPY`, etc.) consumed directly in components. Some components (e.g. `Navbar`) still contain inline strings not yet migrated to `content.ts`; new copy should go in `content.ts`. | ||
|
|
||
| ### Theme system | ||
|
|
||
| `src/lib/ThemeContext.tsx` provides a React Context with `theme`, `toggleTheme`, and `setTheme`. Initial theme is read from `localStorage` (`docugen-theme`) and falls back to `prefers-color-scheme`. Theme is applied by toggling the `dark` class on `<html>`. Tailwind is configured with `darkMode: 'class'`. | ||
|
|
||
| Consume theme in components via the `useTheme` hook from `src/lib/useTheme.ts`. | ||
|
|
||
| ### Design tokens | ||
|
|
||
| Custom Tailwind palette defined in `tailwind.config.js`: | ||
| - `teal-*` — primary accent color (e.g. `text-teal-400`, `bg-teal-600`) | ||
| - `dark-*` / `light-*` — semantic scale for text/backgrounds | ||
| - Fonts: `font-sans` → Inter, `font-mono` → JetBrains Mono | ||
|
|
||
| Avoid arbitrary Tailwind values (`[...]`); extend the theme instead. | ||
|
|
||
| ### Animations | ||
|
|
||
| Use Framer Motion only for entrance animations (`motion.div` with `initial`/`animate`/`whileInView`). Always set `viewport={{ once: true }}`. Duration: `0.5s` standard, `0.6s` complex. Stagger children with `delay: index * 0.1`. No spring or bounce effects. | ||
|
|
||
| ## Code Conventions | ||
|
|
||
| - **Named exports only** — no default exports for components. | ||
| - **Relative imports** — `tsconfig.json` uses `moduleResolution: "bundler"` but has no `baseUrl`/`paths` and `vite.config.ts` has no aliases, so use `./` or `../` paths throughout. | ||
| - **Import order**: React → external packages → internal components/utils. | ||
| - **No `any` types** — ESLint enforces `@typescript-eslint/no-explicit-any: error`. Use `unknown` with type guards. | ||
| - **Unused variables/params** cause build errors (`noUnusedLocals`, `noUnusedParameters` in `tsconfig.json`). Prefix with `_` to suppress if intentional. | ||
| - **Component file order**: imports → types/interfaces → constants → helper functions → main component → exports. | ||
| - **Component naming**: PascalCase for files and components; camelCase for utilities. | ||
|
|
||
| ## Testing | ||
|
|
||
| Unit tests use Vitest + React Testing Library. Test files live **next to** the component they test with a `.test.tsx` extension (e.g. `FAQ.tsx` → `FAQ.test.tsx`). | ||
|
|
||
| `src/test/setup.ts` provides global mocks for every test: | ||
| - `localStorage` — vi.fn() mock (reset `beforeEach`) | ||
| - `IntersectionObserver` — stubbed no-op class | ||
|
|
||
| E2E tests are in `e2e/` using Playwright. They require the dev server to already be running (`npm run dev` in a separate terminal). | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Purpose | | ||
| |---|---| | ||
| | `VITE_PLAUSIBLE_DOMAIN` | Enables Plausible analytics (optional; no analytics if unset) | | ||
|
|
||
| Prefix all client-side env vars with `VITE_` (Vite requirement). | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FAQis eagerly imported (not lazy), but the render order inApp.tsxis:Hero→HowItWorks→Features(lazy) →Testimonials(lazy) →FAQ→Preview(lazy) →Pricing(lazy) →Newsletter(lazy). This meansFAQappears after two lazy-loaded sections, well below the fold. Grouping it withHeroandHowItWorksas "above-fold sections" will mislead an AI assistant about the page layout when reasoning about load order, section sequencing, or above-fold optimisation.