@clipboard-health/ai-rules 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/AGENTS.md +107 -0
  2. package/CLAUDE.md +103 -0
  3. package/README.md +21 -0
  4. package/package.json +27 -0
package/AGENTS.md ADDED
@@ -0,0 +1,107 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ <!-- Source: .ruler/codeStyleAndStructure.md -->
6
+
7
+ # Code style and structure
8
+
9
+ - Write concise, technical TypeScript code with accurate examples.
10
+ - Use functional and declarative programming patterns.
11
+ - Prefer iteration and modularization over code duplication.
12
+ - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
13
+ - Structure files: constants, types, exported functions, non-exported functions.
14
+ - Avoid magic strings and numbers; define constants.
15
+ - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
16
+ - When declaring functions, use the `function` keyword, not `const`.
17
+ - Prefer data immutability.
18
+
19
+ <!-- Source: .ruler/errorHandlingAndValidation.md -->
20
+
21
+ # Error handling and validation
22
+
23
+ - Sanitize user input.
24
+ - Handle errors and edge cases at the beginning of functions.
25
+ - Use early returns for error conditions to avoid deeply nested if statements.
26
+ - Place the happy path last in the function for improved readability.
27
+ - Avoid unnecessary else statements; use the if-return pattern instead.
28
+ - Use guard clauses to handle preconditions and invalid states early.
29
+ - Implement proper error logging and user-friendly error messages.
30
+ - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
31
+
32
+ <!-- Source: .ruler/keyConventions.md -->
33
+
34
+ # Key conventions
35
+
36
+ - You are familiar with the latest features and best practices.
37
+ - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
38
+ - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
39
+ - If there might not be a correct answer or do not know the answer, say so instead of guessing.
40
+
41
+ <!-- Source: .ruler/nestJsApis.md -->
42
+
43
+ # NestJS APIs
44
+
45
+ - Use a three-tier architecture:
46
+ - Controllers in the entrypoints tier translate from data transfer objects (DTOs) to domain objects (DOs) and call the logic tier.
47
+ - Logic tier services call other services in the logic tier and repos and gateways at the data tier. The logic tier operates only on DOs.
48
+ - Data tier repos translate from DOs to data access objects (DAOs), call the database using either Prisma for Postgres or Mongoose for MongoDB, and then translate from DAOs to DOs before returning to the logic tier.
49
+ - Use ts-rest to define contracts using Zod schemas, one contract per resource.
50
+ - A controller implements each ts-rest contract.
51
+ - Requests and responses follow the JSON:API specification, including pagination for listings.
52
+ - Use TypeDoc to document public functions, classes, methods, and complex code blocks.
53
+
54
+ <!-- Source: .ruler/react.md -->
55
+
56
+ # React
57
+
58
+ - Destructure props in function body rather than in function signature
59
+ - Prefer inline JSX rather than extracting variables and functions as variables outside of JSX
60
+ - Use useModalState for any showing/hiding functionality like dialogs
61
+ - Utilize custom hooks to encapsulate and reuse stateful logic
62
+ - When performing data-fetching in a custom hook, always use Zod to define any request and response schemas
63
+ - Use react-hook-form for all form UIs and use zod resolver for form schema validation
64
+ - Use date-fns for any Date based operations like formatting
65
+
66
+ <!-- Source: .ruler/testing.md -->
67
+
68
+ # Testing
69
+
70
+ - Follow the Arrange-Act-Assert convention for tests with newlines between each section.
71
+ - Name test variables using the `mockX`, `input`, `expected`, `actual` convention.
72
+ - Aim for high test coverage, writing both positive and negative test cases.
73
+ - Prefer `it.each` for multiple test cases.
74
+ - Avoid conditional logic in tests.
75
+
76
+ <!-- Source: .ruler/typeScript.md -->
77
+
78
+ # TypeScript usage
79
+
80
+ - Use strict-mode TypeScript for all code; prefer interfaces over types.
81
+ - Avoid enums; use const maps instead.
82
+ - Strive for precise types. Look for type definitions in the codebase and create your own if none exist.
83
+ - Avoid using type assertions like `as` or `!` unless absolutely necessary.
84
+ - Use the `unknown` type instead of `any` when the type is truly unknown.
85
+ - Use an object to pass multiple function params and to return results.
86
+ - Leverage union types, intersection types, and conditional types for complex type definitions.
87
+ - Use mapped types and utility types (e.g., `Partial<T>`, `Pick<T>`, `Omit<T>`) to transform existing types.
88
+ - Implement generic types to create reusable, flexible type definitions.
89
+ - Utilize the `keyof` operator and index access types for dynamic property access.
90
+ - Implement discriminated unions for type-safe handling of different object shapes where appropriate.
91
+ - Use the `infer` keyword in conditional types for type inference.
92
+ - Leverage `readonly` properties for function parameter immutability.
93
+ - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
94
+ - Implement exhaustiveness checking using `never`.
95
+
96
+ <!-- Source: .ruler/uiAndStyling.md -->
97
+
98
+ # UI and Styling
99
+
100
+ - Use Material UI for components and styling and a mobile-first approach.
101
+ - Favor TanStack Query over "useEffect".
102
+
103
+ <!-- Source: .ruler/zOverlay.md -->
104
+
105
+ # Overlay
106
+
107
+ - If an ./OVERLAY.md file exists, read it for additional rules.
package/CLAUDE.md ADDED
@@ -0,0 +1,103 @@
1
+ <!-- Source: .ruler/codeStyleAndStructure.md -->
2
+
3
+ # Code style and structure
4
+
5
+ - Write concise, technical TypeScript code with accurate examples.
6
+ - Use functional and declarative programming patterns.
7
+ - Prefer iteration and modularization over code duplication.
8
+ - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
9
+ - Structure files: constants, types, exported functions, non-exported functions.
10
+ - Avoid magic strings and numbers; define constants.
11
+ - Use camelCase for files and directories (e.g., modules/shiftOffers.ts).
12
+ - When declaring functions, use the `function` keyword, not `const`.
13
+ - Prefer data immutability.
14
+
15
+ <!-- Source: .ruler/errorHandlingAndValidation.md -->
16
+
17
+ # Error handling and validation
18
+
19
+ - Sanitize user input.
20
+ - Handle errors and edge cases at the beginning of functions.
21
+ - Use early returns for error conditions to avoid deeply nested if statements.
22
+ - Place the happy path last in the function for improved readability.
23
+ - Avoid unnecessary else statements; use the if-return pattern instead.
24
+ - Use guard clauses to handle preconditions and invalid states early.
25
+ - Implement proper error logging and user-friendly error messages.
26
+ - Favor `@clipboard-health/util-ts`'s `Either` type for expected errors instead of `try`/`catch`.
27
+
28
+ <!-- Source: .ruler/keyConventions.md -->
29
+
30
+ # Key conventions
31
+
32
+ - You are familiar with the latest features and best practices.
33
+ - You carefully provide accurate, factual, thoughtful answers and are a genius at reasoning.
34
+ - You always write correct, up-to-date, bug-free, fully functional, working, secure, easy-to-read, and efficient code.
35
+ - If there might not be a correct answer or do not know the answer, say so instead of guessing.
36
+
37
+ <!-- Source: .ruler/nestJsApis.md -->
38
+
39
+ # NestJS APIs
40
+
41
+ - Use a three-tier architecture:
42
+ - Controllers in the entrypoints tier translate from data transfer objects (DTOs) to domain objects (DOs) and call the logic tier.
43
+ - Logic tier services call other services in the logic tier and repos and gateways at the data tier. The logic tier operates only on DOs.
44
+ - Data tier repos translate from DOs to data access objects (DAOs), call the database using either Prisma for Postgres or Mongoose for MongoDB, and then translate from DAOs to DOs before returning to the logic tier.
45
+ - Use ts-rest to define contracts using Zod schemas, one contract per resource.
46
+ - A controller implements each ts-rest contract.
47
+ - Requests and responses follow the JSON:API specification, including pagination for listings.
48
+ - Use TypeDoc to document public functions, classes, methods, and complex code blocks.
49
+
50
+ <!-- Source: .ruler/react.md -->
51
+
52
+ # React
53
+
54
+ - Destructure props in function body rather than in function signature
55
+ - Prefer inline JSX rather than extracting variables and functions as variables outside of JSX
56
+ - Use useModalState for any showing/hiding functionality like dialogs
57
+ - Utilize custom hooks to encapsulate and reuse stateful logic
58
+ - When performing data-fetching in a custom hook, always use Zod to define any request and response schemas
59
+ - Use react-hook-form for all form UIs and use zod resolver for form schema validation
60
+ - Use date-fns for any Date based operations like formatting
61
+
62
+ <!-- Source: .ruler/testing.md -->
63
+
64
+ # Testing
65
+
66
+ - Follow the Arrange-Act-Assert convention for tests with newlines between each section.
67
+ - Name test variables using the `mockX`, `input`, `expected`, `actual` convention.
68
+ - Aim for high test coverage, writing both positive and negative test cases.
69
+ - Prefer `it.each` for multiple test cases.
70
+ - Avoid conditional logic in tests.
71
+
72
+ <!-- Source: .ruler/typeScript.md -->
73
+
74
+ # TypeScript usage
75
+
76
+ - Use strict-mode TypeScript for all code; prefer interfaces over types.
77
+ - Avoid enums; use const maps instead.
78
+ - Strive for precise types. Look for type definitions in the codebase and create your own if none exist.
79
+ - Avoid using type assertions like `as` or `!` unless absolutely necessary.
80
+ - Use the `unknown` type instead of `any` when the type is truly unknown.
81
+ - Use an object to pass multiple function params and to return results.
82
+ - Leverage union types, intersection types, and conditional types for complex type definitions.
83
+ - Use mapped types and utility types (e.g., `Partial<T>`, `Pick<T>`, `Omit<T>`) to transform existing types.
84
+ - Implement generic types to create reusable, flexible type definitions.
85
+ - Utilize the `keyof` operator and index access types for dynamic property access.
86
+ - Implement discriminated unions for type-safe handling of different object shapes where appropriate.
87
+ - Use the `infer` keyword in conditional types for type inference.
88
+ - Leverage `readonly` properties for function parameter immutability.
89
+ - Prefer narrow types whenever possible with `as const` assertions, `typeof`, `instanceof`, `satisfies`, and custom type guards.
90
+ - Implement exhaustiveness checking using `never`.
91
+
92
+ <!-- Source: .ruler/uiAndStyling.md -->
93
+
94
+ # UI and Styling
95
+
96
+ - Use Material UI for components and styling and a mobile-first approach.
97
+ - Favor TanStack Query over "useEffect".
98
+
99
+ <!-- Source: .ruler/zOverlay.md -->
100
+
101
+ # Overlay
102
+
103
+ - If an ./OVERLAY.md file exists, read it for additional rules.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @clipboard-health/ai-rules <!-- omit from toc -->
2
+
3
+ Rules for AI agents.
4
+
5
+ ## Table of contents <!-- omit from toc -->
6
+
7
+ - [Install](#install)
8
+ - [Usage](#usage)
9
+ - [Local development commands](#local-development-commands)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @clipboard-health/ai-rules
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ## Local development commands
20
+
21
+ See [`package.json`](./package.json) `scripts` for a list of commands.
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@clipboard-health/ai-rules",
3
+ "description": "Rules for AI agents.",
4
+ "version": "0.1.2",
5
+ "bugs": "https://github.com/ClipboardHealth/core-utils/issues",
6
+ "dependencies": {
7
+ "@intellectronica/ruler": "0.3.10",
8
+ "tslib": "2.8.1"
9
+ },
10
+ "exports": {
11
+ "./*": "./*.md"
12
+ },
13
+ "keywords": [],
14
+ "license": "MIT",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "repository": {
19
+ "directory": "packages/ai-rules",
20
+ "type": "git",
21
+ "url": "git+https://github.com/ClipboardHealth/core-utils.git"
22
+ },
23
+ "scripts": {
24
+ "apply": "ruler apply && prettier --write *.md"
25
+ },
26
+ "type": "commonjs"
27
+ }