Skip to content

Generate a .cursorrules File for a QA Codebase

Updated 2026-06-08·intermediate·AI Agent Workflows

Returns a `.cursorrules` file tailored for QA work — locator preferences, anti-patterns to avoid, test naming conventions, assertion style, and rules for asking clarification before fabricating selectors or test data.

When to use it

  • Adding Cursor IDE to a QA codebase.
  • Reducing time spent fixing Cursor's auto-generated tests.
  • Standardizing AI assistance across QA engineers using Cursor.
  • Migrating from generic .cursorrules to QA-specific.

The prompt

XML-tagged — best for Claude 4.x

<role>
You are a Cursor power user. You know that .cursorrules dramatically improves output quality but only if rules are specific to the QA domain — generic rules ("write clean code") add no value.
</role>

<context>
.cursorrules is loaded into every prompt Cursor sends to its underlying model. Good content:
- Locator preferences (which to use, which to avoid)
- Test naming conventions
- Assertion patterns
- Anti-patterns to NEVER produce
- "Ask before guessing" rules (selectors, test data, env vars)
- Framework-specific gotchas (Cypress chaining, Playwright auto-waiting, Vitest mocking semantics)

The file is plain markdown / text. Keep < 150 lines; longer dilutes signal.
</context>

<task>
Generate a `.cursorrules` with these sections:
1. Project context (1-2 sentences)
2. When generating tests
3. When generating POMs
4. Anti-patterns to NEVER produce
5. Ask for clarification rules
6. Style conventions
</task>

<input>
Project framework: {framework}
Language: {language}
Locator strategy: {locator_strategy}
Test data convention: {test_data}
Known anti-patterns from your codebase: {anti_patterns}
</input>

<constraints>
- Rules SPECIFIC, not generic ("Use data-testid first, not class selectors").
- Anti-patterns called out by NAME (waitForTimeout, magic numbers, etc.).
- "Ask before guessing" must be explicit (clarify which scenarios).
- Style conventions named, not implied.
- 80-150 lines total.
</constraints>

<output_format>
A complete `.cursorrules` file as a Markdown code block.
</output_format>

Before writing, identify the 3-5 most common pain points in this team's Cursor output and address them in the file.

Example

Common pitfalls

  • Rules become generic ('write good code'); force specifics tied to your stack.
  • Anti-patterns called out without naming the specific construct (e.g., 'avoid waits' vs 'no page.waitForTimeout').
  • Ask-before-guessing rules missing; Cursor fabricates selectors / data without asking.
  • .cursorrules file balloons past 200 lines; signal dilutes. Keep tight.

Tips

  • Test the .cursorrules by giving Cursor a small task and watching the output; refine rules iteratively.
  • Pair with `claude-md-for-qa` for the Claude Code equivalent in the same repo.
  • Refresh when major framework versions land (Playwright 1.50 → 1.55, etc.).
  • Document team-specific style conventions in the file; they get applied automatically across all Cursor invocations.

FAQ

Cursor (most popular in 2026): native AI IDE with .cursorrules + composer + commands. Continue: open-source VS Code extension; similar concept. Cody (Sourcegraph): code-search powered AI; great for large codebases. All accept similar instruction files; the format differs.

Related prompts