Generate a CLAUDE.md File for a QA Project with AI
Reads a description of your QA project (framework, language, conventions, CI setup) and returns a ready-to-commit `CLAUDE.md` covering project structure, allowed bash commands, test execution workflow, code conventions, and 'do/do not' rules tailored to QA work: making Claude Code dramatically more useful in your repo.
When to use it
- Onboarding Claude Code into an existing QA codebase.
- Standardizing AI-assistant context across QA repos in an org.
- Documenting conventions for engineers (CLAUDE.md is also a human-readable contributor guide).
- Migrating from .cursorrules or similar to CLAUDE.md.
The prompt
<role>You are a Claude Code power user with months of experience configuring CLAUDE.md for QA projects. You know what works (specific test commands, framework conventions, explicit Don'ts) and what fails (vague aspirations, generic platitudes).</role> <context>A good CLAUDE.md for a QA project includes:1. **Project orientation**: what this repo is, primary language, framework2. **Workspace structure**: where tests live, where source lives, monorepo layout3. **Test commands**: exact commands to run tests at every level (unit / integration / E2E)4. **Conventions**: naming, file layout, locator strategy, assertion style5. **Allowed bash commands**: commands the agent can run autonomously6. **Don'ts**: explicit anti-patterns to avoid (no `it.only`, no `waitForTimeout`, no committed test artifacts)7. **Test data**: where fixtures live, factory pattern, secret handling8. **Debugging**: how to view traces, screenshots, logs9. **Linting and pre-commit**: how lint/typecheck is run; lint-fix commands The file becomes part of every Claude Code invocation; verbose pays off, vague doesn't.</context> <task>For the QA project described below, generate a CLAUDE.md with these sections:1. Project orientation (2-3 sentences)2. Workspace structure3. Test commands (per type)4. Conventions5. Allowed bash commands (whitelist)6. Don'ts (explicit anti-patterns)7. Test data + secrets handling8. Debugging + tracing9. Linting + pre-commit</task> <input>Project framework: {framework}Language and stack: {stack}Monorepo / single-repo: {repo_type}Test conventions (naming, locator priority, assertion style): {conventions}CI / commands (test, lint, build): {ci}Team-specific Don'ts (e.g., no inline secrets): {donts}</input> <constraints>- Test commands are EXACT shell strings, not "run the tests".- Allowed bash commands are an explicit whitelist. CLAUDE.md is guidance only and cannot grant permissions, so also output the matching `.claude/settings.json` `permissions.allow` entries (e.g. `"Bash(pnpm test:*)"`).- Follow the input conventions exactly (e.g. the user's locator priority), even where you would choose differently.- Pass extra CLI flags to pnpm scripts directly (`pnpm test:e2e --project=chromium`), not after `--`.- Don'ts are SPECIFIC anti-patterns ("no `page.waitForTimeout`", not "no flaky tests").- File should be 80-150 lines; verbose enough to be useful, not so long it dilutes.- Use Markdown headings (H2 sections, H3 subsections).</constraints> <output_format>A complete CLAUDE.md inside a FOUR-backtick fence (````markdown), so the three-backtick code blocks inside it don't close the outer block, followed by a brief "Customization notes" paragraph on what to tweak per repo (e.g., test runner version, branch naming).</output_format> <approach>Before writing, identify which Don'ts will save the agent (and you) the most pain.</approach>## RoleClaude Code power user. Configure CLAUDE.md for QA projects. Specific > vague. ## ContextGood CLAUDE.md includes:1. Project orientation2. Workspace structure3. Test commands (exact)4. Conventions5. Allowed bash whitelist6. Don'ts (specific anti-patterns)7. Test data + secrets8. Debugging + tracing9. Linting + pre-commit CLAUDE.md gets loaded per invocation. Verbose pays; vague doesn't. ## TaskGenerate CLAUDE.md with 9 sections. ## Input- Framework: {framework}- Stack: {stack}- Repo type: {repo_type}- Conventions: {conventions}- CI commands: {ci}- Team Don'ts: {donts} ## Constraints- Test commands = EXACT shell strings.- Allowed bash = explicit whitelist; CLAUDE.md can't grant permissions, so also output matching `.claude/settings.json` `permissions.allow` entries.- Follow the input conventions exactly (e.g. locator priority).- pnpm script flags passed directly (`pnpm test:e2e --project=chromium`), not after `--`.- Don'ts SPECIFIC, not general.- 80-150 lines.- Markdown H2/H3. ## Output formatCLAUDE.md inside a four-backtick fence (````markdown) so inner code blocks survive + Customization notes paragraph. ## ApproachIdentify Don'ts that save most pain.Example
Input
Project framework: Playwright 1.62+ for E2E; Vitest for unit + integration Language and stack: TypeScript strict; Node 24 LTS; pnpm; Next.js 15 frontend (separate repo) Monorepo / single-repo: Single repo (just the QA / E2E suite) Test conventions: data-testid > role > label; assertX() for assertions; describe per feature; one file per feature area CI commands: pnpm test (Vitest), pnpm test:e2e (Playwright), pnpm lint (ESLint), pnpm typecheck (tsc --noEmit), pnpm build Team-specific Don'ts: no test data in plaintext; no real customer emails; no it.only / test.only on main; no console.log committed; no waitForTimeout
Output
````markdown
# CLAUDE.md: QA Project Instructions
## 1. Project orientation
This repo is the end-to-end test suite for the main product. We use Playwright for browser tests and Vitest for unit + integration tests. The product source lives in a separate repo (`product-app`).
Primary language: TypeScript (strict mode).
Runtime: Node 24 LTS.
Package manager: pnpm.
## 2. Workspace structure
```
src/
├── pages/ # POM classes: one per page or component
├── fixtures/ # Playwright fixtures (auth, test users, common setup)
├── utils/ # Pure utility functions (no browser logic)
└── data/ # Static test data (NOT secrets)
tests/
├── e2e/ # Playwright specs grouped by feature
│ ├── checkout/
│ ├── billing/
│ └── account/
└── integration/ # Vitest integration tests (API + DB layer)
```
One spec file per feature area (e.g., `tests/e2e/checkout/discount-flow.spec.ts`).
## 3. Test commands
Exact commands to run tests:
```bash
# Unit + Integration (Vitest)
pnpm test # run all unit + integration tests
pnpm test:unit # unit only
pnpm test:integration # integration only
pnpm test --coverage # with coverage report
# E2E (Playwright)
pnpm test:e2e # all E2E specs
pnpm test:e2e --project=chromium # one browser only
pnpm test:e2e tests/e2e/checkout/ # one directory
pnpm test:e2e --debug # Playwright Inspector, headed, step by step
# Lint + Typecheck (must be green before commit)
pnpm lint
pnpm typecheck
# Build
pnpm build
```
## 4. Conventions
- **Locator priority** (strict, team rule): `getByTestId` > `getByRole` > `getByLabel` > CSS (last resort, with a comment).
- **POM pattern**: One class per page. Locators initialized in constructor. Action methods named in verb form (`signIn`, `addToCart`). Assertion methods prefixed `assertX()`.
- **Test names**: Describe BEHAVIOR, "signs in with valid credentials and redirects to dashboard", not "test login".
- **Describe blocks**: One per feature. Use nested describes for sub-features.
- **Test data**: Use factories from `src/fixtures/`: do NOT inline test data in specs.
- **Assertions**: `expect(locator).toBeVisible()` not `toBeTruthy()`. `toEqual` not `toBe` for object comparisons. Always use Playwright's auto-waiting expects, never `.then()`.
- **Imports**: Use absolute paths from `@/` (configured in tsconfig).
## 5. Allowed bash commands (autonomous use)
The agent may run these without confirmation:
```
pnpm install
pnpm test
pnpm test:unit
pnpm test:integration
pnpm test:e2e
pnpm test:e2e --grep <feature>
pnpm lint
pnpm typecheck
pnpm build
git status
git diff
git diff --staged
git log --oneline -10
npx playwright show-report
npx playwright codegen <url>
ls
find . -name "*.spec.ts"
grep -r "<pattern>" tests/
```
For any command not on this list, ask first. The same list lives in `.claude/settings.json`, because CLAUDE.md alone does not grant permissions:
```json
{
"permissions": {
"allow": ["Bash(pnpm test:*)", "Bash(pnpm lint)", "Bash(pnpm typecheck)", "Bash(git diff:*)", "Bash(npx playwright show-report)"]
}
}
```
## 6. Don'ts (strict rules: NEVER do these without explicit override)
- **NO `page.waitForTimeout()` or hard sleeps.** Always use Playwright auto-waiting (`expect(...).toBeVisible()` etc.).
- **NO `it.only` / `test.only` / `.skip` in committed code.** Use them locally only; remove before commit.
- **NO inline secrets, real customer data, or PII.** Use the `@test.example.com` test domain or `.env` (gitignored).
- **NO real customer emails or names in test data.** Use the test user factory.
- **NO `console.log` debugging in committed code.** Use Playwright's `test.info().annotations` if you need persistent notes.
- **NO CSS-based locators when testid / role / label exists.** Surface to author if no other locator works.
- **NO commits to main without PR review.**
- **NO direct edits to `playwright-report/` or `test-results/`**: these are generated; should be gitignored.
## 7. Test data + secrets handling
- Test users: factory in `src/fixtures/users.ts`. Email pattern: `<role>_<timestamp>@test.example.com`.
- Static data: `src/data/`. Never put PII or production data here.
- Secrets: `.env` (gitignored). Required vars: `BASE_URL`, `TEST_BEARER`, `STAGING_DB_URL`. Use `process.env.X` in code.
- Database state: tests use staging; no production access.
## 8. Debugging + tracing
- Playwright traces: `npx playwright show-report` after a failed run opens the HTML report with traces.
- Re-run a single failed test in headed mode: `pnpm test:e2e --headed -g "test name"`.
- VS Code extension "Playwright Test for VSCode" supports inline run + debug.
- Failed trace + screenshots are in `test-results/`; reviewed via report only, never committed.
## 9. Linting + pre-commit
- Pre-commit hook runs lint + typecheck via Husky (configured). If you bypass with `--no-verify`, the PR will be blocked by CI anyway.
- Lint auto-fix: `pnpm lint --fix`.
- Type errors must be resolved before commit; they cannot be deferred via `@ts-ignore` without justification in a comment.
---
## Workflow when making changes
1. Run `pnpm test` and `pnpm test:e2e` to confirm baseline is green.
2. Make your changes.
3. Add or update tests covering the change.
4. Run `pnpm lint` and `pnpm typecheck` until green.
5. Run `pnpm test` (and `pnpm test:e2e` if relevant) to confirm your test passes.
6. Commit with a conventional commit message (`feat:`, `fix:`, `test:`, etc.).
````
## Customization notes
Adjust for your repo:
- Replace `@test.example.com` with a test domain your team owns.
- Copy the `permissions.allow` block into `.claude/settings.json`; widen or narrow it there, not only in CLAUDE.md.
- Update CI commands if you use yarn / npm instead of pnpm.
- If you have a different POM convention (e.g., async getters instead of constructor-init locators), update Section 4.
- Add a "Project-specific terminology" section if your domain uses jargon (e.g., "an order is an Invoice in our codebase").
- If using monorepo, expand Section 2 to show the workspace boundaries.Common pitfalls
- Generic CLAUDE.md ('write clean code'): adds no signal. Force specific commands and Don'ts.
- Allowed bash list written only into CLAUDE.md: Claude Code still prompts for every command, because permissions come from `.claude/settings.json` (`permissions.allow`). Keep the two lists in sync.
- Don'ts get listed as wishes ('avoid technical debt') instead of testable rules ('no \`waitForTimeout\`'). Demand specificity.
- File grows past 200 lines; verbosity dilutes the most important rules. Stay 80-150 lines.
Tips
- Test the CLAUDE.md by running Claude Code on a small task; if the agent makes a common mistake, add a Don't.
- Re-tune monthly; conventions drift, new anti-patterns emerge.
- Keep CLAUDE.md and your CONTRIBUTING.md in sync: most rules apply to humans too.
- Pair with `cursorrules-qa` if your team uses Cursor IDE alongside Claude Code.
FAQ
CLAUDE.md vs .cursorrules?
CLAUDE.md is for Claude Code (Anthropic's CLI/IDE agent). .cursorrules is for Cursor IDE. Format is similar; the file loaded depends on the tool. Most teams maintain both with similar content.
What to put in user-level CLAUDE.md vs project-level?
Project-level: conventions specific to this repo (frameworks, commands, Don'ts). User-level: personal preferences (e.g., always wait for green CI before commit). User-level is per-developer; project-level is shared.
Security implications of allowed commands?
The list in CLAUDE.md is only guidance; what actually runs without a prompt is set in `.claude/settings.json` under `permissions.allow` (and blocked under `permissions.deny`). Don't allow destructive commands (rm -rf, git push --force) without specific scoping. Read-only commands (ls, grep, git diff) are safe. Test running commands should be allowed; deploy commands generally should not.
How is this different from a contributing guide?
CLAUDE.md is structured for AI agents: specific commands, exact patterns. A CONTRIBUTING guide is for humans: narrative, broader context. The structured format of CLAUDE.md happens to also be very useful for new human contributors, so think of it as both.