Generate strictly typed TypeScript: strict plus chosen extra checks, explicit return types on exported APIs, no any, derived types, sound guards, typed errors, small generic utilities and TSDoc.
.devin/rules/windsurf-typescript-strict-patterns.md. Downloaded files need to be placed in that repository path.---
trigger: glob
globs: "**/*"
---
When generating TypeScript:
1. Compiler options: `strict: true` (the default since TypeScript 6.0; keep it explicit) plus the project's extra checks, typically `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitReturns` and `noImplicitOverride`. Generated code must pass `tsc --noEmit` with them.
2. Return types: declare them on exported functions, public methods and callbacks that form an API; let TypeScript infer them for local helpers.
3. No `any`: use `unknown` and narrow, generics where a type flows through, or a schema validator for external data. No `as any` or `as unknown as T` to silence errors.
4. Types: derive instead of duplicating (`z.infer`, `ReturnType`, `typeof`, indexed access types, `Pick`/`Omit`); model variants as discriminated unions.
5. Type guards: use them where narrowing by `typeof`/`in`/discriminant is not enough, and make them check every property they claim.
6. Error types: use `Error` subclasses with `cause` for exceptions and a `Result` union with literal error codes for expected failures; treat `catch` variables as `unknown`.
7. Generic utilities: create one only when it is used in several places and its type parameters link inputs and outputs; prefer built-in utility types.
8. Documentation: TSDoc comments on exported APIs (`@param`, `@returns`, `@throws`, `@typeParam`), describing behaviour that the types cannot express.
```ts
/**
* Parses a positive integer from a query-string value.
* @returns The parsed number, or `undefined` when the value is absent.
* @throws {RangeError} When the value is present but not a positive integer.
*/
export function parsePositiveInt(value: string | null): number | undefined {
if (value === null || value === '') return undefined;
const n = Number(value);
if (!Number.isInteger(n) || n <= 0) throw new RangeError(`Expected a positive integer, got "${value}"`);
return n;
}
```
TypeScript type guards: typeof, instanceof, in, discriminated unions, user-defined predicates, assertion functions, inferred predicates and exhaustive never checks.
Add performance monitoring and analytics
Generate React forms with react-hook-form and Zod: shared schemas, labelled field components, accessible error messages, async validation, submission state and tests.
Windsurf
language
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
Windsurf-generated utilities in a strict TypeScript project use `any` for parsed query values and have no return types or docs on exported functions.
Generate src/lib/query.ts with helpers to read page and pageSize from URLSearchParams, following the strict TypeScript patterns rule.
Exported helpers with explicit return types and TSDoc (@returns/@throws), unknown/null handling instead of any, RangeError for invalid values, and code that passes tsc --noEmit with strict and noUncheckedIndexedAccess.
Windsurf's rules documentation (docs.windsurf.com/windsurf/cascade/memories) now redirects to Devin documentation, which describes rules for the Devin Local agent in Devin Desktop. Current rules live in .devin/rules/*.md with a trigger setting, and the legacy Windsurf files (.windsurf/rules/*.md, .windsurf/global_rules.md and .windsurfrules) are still imported by default. AGENTS.md files are read as always-on rules.
.devin/rules/windsurf-typescript-strict-patterns.mdStarting point, not a tested configuration for your repository. Applied when files matching globs are involved (trigger: glob). Review the instructions, adapt the file paths and run your project's existing checks.
---
trigger: glob
globs: "**/*"
---
When generating TypeScript:
1. Compiler options: `strict: true` (the default since TypeScript 6.0; keep it explicit) plus the project's extra checks, typically `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`, `noImplicitReturns` and `noImplicitOverride`. Generated code must pass `tsc --noEmit` with them.
2. Return types: declare them on exported functions, public methods and callbacks that form an API; let TypeScript infer them for local helpers.
3. No `any`: use `unknown` and narrow, generics where a type flows through, or a schema validator for external data. No `as any` or `as unknown as T` to silence errors.
4. Types: derive instead of duplicating (`z.infer`, `ReturnType`, `typeof`, indexed access types, `Pick`/`Omit`); model variants as discriminated unions.
5. Type guards: use them where narrowing by `typeof`/`in`/discriminant is not enough, and make them check every property they claim.
6. Error types: use `Error` subclasses with `cause` for exceptions and a `Result` union with literal error codes for expected failures; treat `catch` variables as `unknown`.
7. Generic utilities: create one only when it is used in several places and its type parameters link inputs and outputs; prefer built-in utility types.
8. Documentation: TSDoc comments on exported APIs (`@param`, `@returns`, `@throws`, `@typeParam`), describing behaviour that the types cannot express.
```ts
/**
* Parses a positive integer from a query-string value.
* @returns The parsed number, or `undefined` when the value is absent.
* @throws {RangeError} When the value is present but not a positive integer.
*/
export function parsePositiveInt(value: string | null): number | undefined {
if (value === null || value === '') return undefined;
const n = Number(value);
if (!Number.isInteger(n) || n <= 0) throw new RangeError(`Expected a positive integer, got "${value}"`);
return n;
}
```
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
The docs recommend keeping rules short and specific. The current docs say AGENTS.md, AGENTS.local.md and AGENT.md are read as always-on rules, including files in subdirectories. Use .devin/rules/ when you need glob, model-decision or manual triggers.
Documentation checked 2026-11-05: Devin docs: Local customizations (redirect target of Windsurf memories docs)Windsurf docs: Cascade memories (redirects)
TypeScript type guards: typeof, instanceof, in, discriminated unions, user-defined predicates, assertion functions, inferred predicates and exhaustive never checks.
Add performance monitoring and analytics
Generate React forms with react-hook-form and Zod: shared schemas, labelled field components, accessible error messages, async validation, submission state and tests.