Skip to main content
rule

ai-agent-specialist — Cursor rule: what it does, how to install

This Cursor rule sets guidance for TypeScript, React, and Node.js, covering architecture, tests, security, errors, and Git. It suits projects that need WHY explanations.

Install into Cursor · Manually: put the files in place All methods and platforms ↓
.cursor/rules/ai-agent-specialist.mdc
Open on GitHub

What ai-agent-specialist does

The rule guides Cursor while working on TypeScript, React, and Node.js code. It asks for strict typing without any, limits functions to twenty lines, defines naming conventions, and favors interfaces for objects. Each guideline includes a WHY explanation that gives the reasoning behind it.

Its architecture section calls for Clean Architecture, dependency inversion, and the repository pattern. React Query handles server state and Zustand handles client state; Redux is excluded. The rule also covers an AppError hierarchy, Result values, Winston logging, Zod validation, rate limiting, helmet, and test targets of 80% unit coverage and 100% coverage for critical paths. The file targets **/*, while alwaysApply is false.

For Git, it sets a 400-line PR limit and Conventional Commit types: feat, fix, refactor, test, and docs. A project that already uses Redux will need to reconcile that setup with the rule’s direct “No Redux” requirement.

What it helps with

  • enforce strict TypeScript conventions
  • separate domain logic from persistence
  • handle expected and exceptional failures differently
  • validate API input with Zod schemas
  • set testing and pull request boundaries

Example prompts for the agent

  • Review this module against the TypeScript rules and extract functions longer than twenty lines.
  • Design this feature with Clean Architecture and the repository pattern.
  • Add Zod validation at the API boundary and keep tokens out of logs.

How to install ai-agent-specialist

Manually: put the files in place

.cursor/rules/ai-agent-specialist.mdc

Frontmatter: description, globs, alwaysApply

Step by step, with commands for each platform: Cursor rules: .mdc files, four modes and what replaced .cursorrules

Questions about ai-agent-specialist

How do I install ai-agent-specialist in Cursor?

Create the file .cursor/rules/ai-agent-specialist.mdc in the project.

What does ai-agent-specialist do?

It gives Cursor guidance for TypeScript, React, and Node.js, including architecture, testing, error handling, security, and Git. Each rule includes a WHY explanation.

What does the rule require for React state management?

It assigns server state to React Query and client state to Zustand. Redux is explicitly excluded.

Source text

ai-agent-specialist.mdc · CC0-1.0
---
description: "Cursor rules for TypeScript, React, Node.js, clean architecture, testing, and WHY-oriented engineering guidance."
globs: **/*
alwaysApply: false
---
You are a senior full-stack developer specializing in TypeScript, React, and Node.js.
Every rule includes a WHY explanation for the reasoning behind it.

## Coding Standards
- Use strict TypeScript. Never use `any`. Use `unknown` for dynamic data.
  > WHY: Type safety prevents runtime errors and improves developer experience.
- Max function length: 20 lines. Extract helpers for complex logic.
  > WHY: Improves testability, readability, and makes code review easier.
- Naming: camelCase for variables/functions, PascalCase for classes/interfaces, UPPER_SNAKE for constants.
  > WHY: Consistent with TypeScript ecosystem standards.
- Prefer interfaces over type aliases for objects.
  > WHY: Interfaces are extendable and produce better error messages.

## Architecture
- Clean Architecture with dependency inversion. Domain layer is framework-agnostic.
  > WHY: Testable business logic that survives framework changes.
- Repository pattern for data access. Never call ORM directly from business logic.
  > WHY: Decouples persistence from domain, enables testing with in-memory implementations.
- React Query for server state, Zustand for client state. No Redux.
  > WHY: Lighter weight, better TypeScript support, less boilerplate.

## Error Handling
- Custom AppError hierarchy with HTTP status codes. Throw for exceptional, return Result for expected failures.
  > WHY: Clear intent — callers know which errors to catch vs handle.
- Structured logging with Winston. Never log sensitive data (passwords, tokens, PII).
  > WHY: Observability without security risk. Structured logs enable alerting.

## Testing
- 80% unit coverage, 100% critical paths. Use factory functions for test data.
  > WHY: Factory functions are maintainable and composable. Fixtures become stale.
- Mock only external dependencies (APIs, DB). Never mock internal logic.
  > WHY: Tests should reflect reality. Over-mocking hides real bugs.

## Security
- Validate all input with Zod schemas at API boundaries.
  > WHY: Runtime validation catches what TypeScript can't — malformed external data.
- Rate limit all public endpoints. Use helmet middleware.
  > WHY: Defense in depth against abuse and common web vulnerabilities.

## Git
- Max 400 lines per PR. Conventional commits: feat/fix/refactor/test/docs.
  > WHY: Small PRs get reviewed faster and have fewer bugs.

© PatrickJS · CC0-1.0 · PatrickJS/awesome-cursorrules

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set210

ascii-simulation-game-cursorrules-prompt-file A Cursor rule that frames an observer-only ASCII simulation: 10x10 grid, turn-based play, logs for nearly everything. Useful if you are building something in the spirit of Conway's Game of Life. ★ 41,024repo stars anti-sycophancy-code-discipline-cursorrules-prompt-file This Cursor rule stops the assistant from sycophantic approval, fake API signatures, and unverified reviews. It keeps refactoring disciplined and forces evidence-based checks. ★ 41,024repo stars anti-overengineering This Cursor rule keeps edits tied to the request and avoids extra abstractions, dependencies, and broad file rewrites. ★ 41,024repo stars ankra-cli A Cursor rule that tells the agent how to drive the Ankra CLI: clusters, stacks, Helm releases and tokens. ★ 41,024repo stars angular-typescript-cursorrules-prompt-file Sets Angular 18 and TypeScript standards in Cursor, capping nesting depth at two levels and enforcing Jest test conventions. ★ 41,024repo stars angular-novo-elements-cursorrules-prompt-file This rule guides Cursor through Angular work with Novo Elements, favoring small diffs, checks, and tests. It fits projects built with standalone components. ★ 41,024repo stars android-jetpack-compose-cursorrules-prompt-file A Cursor rule that steers the agent through Android development with Jetpack Compose: architecture, state, tests. ★ 41,024repo stars alpha-skills-quant-factor-research Sets up Cursor as a quantitative researcher to design, evaluate, and backtest alpha factors. Supports US, Hong Kong, and China A-share equity markets. ★ 41,024repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor