Skip to content

Commit 6872bde

Browse files
committed
chore: designate AGENTS.md as single source of truth for AI configs
Reduce duplication by keeping only compact rule bullets in .cursorrules and copilot-instructions.md, with a reference to AGENTS.md for full examples and detailed standards.
1 parent 63f2986 commit 6872bde

3 files changed

Lines changed: 14 additions & 140 deletions

File tree

.cursorrules

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# react-simplikit Cursor Rules
22

3+
> Full coding standards with examples: see AGENTS.md
4+
35
## Project
46

57
React hooks/components library. Monorepo: `packages/core` + `packages/mobile`.
68

79
## Architecture
810

911
Unidirectional layers: `components → hooks → utils → _internal`
10-
Mobile depends on core. Core must NOT depend on mobile.
12+
Core and mobile are independent packages. No cross-package dependencies.
1113

1214
## Code Style
1315

@@ -16,62 +18,10 @@ Mobile depends on core. Core must NOT depend on mobile.
1618
- Named exports only, no default exports
1719
- No `any` — strict TypeScript
1820
- `.ts`/`.tsx` extensions in source imports (tsup converts to `.js`)
19-
- Strict boolean checks: `value !== undefined` not `if (value)`
21+
- No implicit boolean coercion: `if (value)` → `if (value != null)` (enforced by `strict-boolean-expressions`)
22+
- Nullish checks: `== null` for both null and undefined, `!== undefined` only when distinction matters
2023
- Zero runtime dependencies
2124
- Always return cleanup in useEffect to remove listeners
22-
- Nullish checks: `== null` for both null and undefined, `!== undefined` only when distinction matters
2325
- Early returns (guard clauses) over nested if-else blocks
2426
- Function declarations use `function` keyword, not arrow: `function toggle(state: boolean) { return !state; }`
2527
- Short inline callbacks (map, filter args) are OK with arrow functions
26-
27-
## SSR-Safe Pattern
28-
29-
```ts
30-
const [state, setState] = useState(FIXED_INITIAL_VALUE);
31-
useEffect(function syncBrowserState() {
32-
if (isServer()) return;
33-
setState(getBrowserAPI());
34-
}, []);
35-
```
36-
37-
## Hook Returns
38-
39-
- 1 value → direct return
40-
- 2 values → tuple `[state, action]`
41-
- 3+ values → object `{ a, b, c }`
42-
43-
## Testing
44-
45-
- 100% coverage (Vitest)
46-
- SSR tests required for browser API hooks (`.ssr.test.ts`)
47-
- Use `renderHookSSR.serverOnly()` for SSR tests
48-
49-
## File Structure
50-
51-
Each hook in own folder: `src/hooks/useHookName/`
52-
53-
- `index.ts`, `useHookName.ts`, `useHookName.spec.ts` (core) / `.test.ts` (mobile), `useHookName.ssr.test.ts`
54-
- Docs: `useHookName.md` + `ko/useHookName.md`
55-
56-
## JSDoc
57-
58-
Required tags: `@description`, `@param`, `@returns`, `@example`
59-
60-
## Performance
61-
62-
- Throttle subscriptions at ~16ms (60fps)
63-
- Use `startTransition` for non-urgent state updates
64-
65-
## Commands
66-
67-
```bash
68-
yarn build # Build all (tsup)
69-
yarn test # Run tests (Vitest)
70-
yarn fix # Auto-fix lint + format
71-
yarn typecheck # Type check (tsc --noEmit)
72-
```
73-
74-
## Commits
75-
76-
Format: `<type>(<scope>): <description>`
77-
Types: feat, fix, docs, chore, refactor, test

.github/copilot-instructions.md

Lines changed: 7 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Copilot Instructions for react-simplikit
22

3+
> Full coding standards with examples: see [AGENTS.md](../../AGENTS.md)
4+
35
## Quick Reference
46

57
- Monorepo: `packages/core` (react-simplikit) + `packages/mobile` (@react-simplikit/mobile)
68
- Architecture: `components → hooks → utils → _internal` (unidirectional, no circular imports)
7-
- Mobile depends on core; core must NOT depend on mobile
9+
- Core and mobile are independent packages — no cross-package dependencies
810

911
## Code Style Rules
1012

@@ -13,88 +15,10 @@
1315
- No default exports — named exports only
1416
- No `any` types — strict TypeScript
1517
- Use `.ts`/`.tsx` extensions in source imports (tsup converts to `.js`)
16-
- Strict boolean checks: `value !== undefined` not `if (value)`
18+
- No implicit boolean coercion: `if (value)``if (value != null)` (enforced by `strict-boolean-expressions`)
19+
- Nullish checks: `== null` for both null and undefined, `!== undefined` only when distinction matters
1720
- Zero runtime dependencies
1821
- Always return cleanup in useEffect to remove listeners
19-
- Nullish checks: use `== null` for both null and undefined:
20-
```ts
21-
if (ref == null) { continue; }
22-
items.filter(item => item != null);
23-
const controlled = valueProp !== undefined; // only when distinction matters
24-
```
2522
- Prefer early returns (guard clauses) over nested if-else blocks
26-
- Function declarations use `function` keyword, not arrow functions:
27-
```ts
28-
// ✅ function toggle(state: boolean) { return !state; }
29-
// ✅ items.filter(item => item != null) ← inline callback arrow OK
30-
// ❌ const toggle = (state: boolean) => !state;
31-
```
32-
33-
## SSR-Safe Pattern (CRITICAL)
34-
35-
All browser API access must use this pattern:
36-
37-
```ts
38-
const [state, setState] = useState(FIXED_INITIAL_VALUE);
39-
useEffect(function syncBrowserState() {
40-
if (isServer()) return;
41-
setState(getBrowserAPI());
42-
}, []);
43-
```
44-
45-
Never call browser APIs during state initialization.
46-
47-
## Hook Return Values
48-
49-
- 1 value → return directly: `useDebounce<T>(value, delay): T`
50-
- 2 values → tuple: `useToggle(init): [boolean, () => void]`
51-
- 3+ values → object: `usePagination(): { page, nextPage, prevPage }`
52-
53-
## Testing
54-
55-
- 100% coverage required (Vitest)
56-
- SSR test required for browser API hooks:
57-
```ts
58-
import { renderHookSSR } from '../../_internal/test-utils/renderHookSSR.tsx';
59-
it('is safe on server side rendering', () => {
60-
const result = renderHookSSR.serverOnly(() => useHookName());
61-
expect(result.current).toBeDefined();
62-
});
63-
```
64-
65-
## JSDoc Template
66-
67-
Every public API requires:
68-
69-
````ts
70-
/**
71-
* @description Brief description of what it does
72-
* @param paramName - Parameter description
73-
* @returns What the hook/function returns
74-
* @example
75-
* ```ts
76-
* const value = useHookName(param);
77-
* ```
78-
*/
79-
````
80-
81-
## File Structure
82-
83-
```
84-
src/hooks/useHookName/
85-
├── index.ts # Re-export
86-
├── useHookName.ts # Implementation
87-
├── useHookName.spec.ts # Tests (core) / useHookName.test.ts (mobile)
88-
├── useHookName.ssr.test.ts # SSR tests
89-
├── useHookName.md # English docs
90-
└── ko/useHookName.md # Korean docs
91-
```
92-
93-
## Commands
94-
95-
```bash
96-
yarn build # Build all packages (tsup)
97-
yarn test # Run tests (Vitest)
98-
yarn fix # Auto-fix lint + format
99-
yarn typecheck # Type check (tsc --noEmit)
100-
```
23+
- Function declarations use `function` keyword, not arrow functions
24+
- Short inline callbacks (map, filter args) are OK with arrow functions

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ components → hooks → utils → _internal
2121
- Components may use hooks, utils, \_internal
2222
- Hooks may use utils, \_internal
2323
- Utils may use \_internal only
24-
- Mobile may depend on core; core must NOT depend on mobile
24+
- Core and mobile are independent packages — no cross-package dependencies
2525

2626
## File Structure
2727

@@ -42,7 +42,7 @@ src/hooks/useHookName/
4242

4343
- **`type` over `interface`** — Always use `type` for type aliases
4444
- **Named functions in useEffect**`useEffect(function handleResize() { ... }, [])` not arrow functions
45-
- **Strict boolean checks**`value !== undefined` not `if (value)`
45+
- **No implicit boolean coercion**`if (value)` `if (value != null)` (enforced by `strict-boolean-expressions`)
4646
- **Import extensions** — Use `.ts`/`.tsx` extensions in source imports (tsup converts to `.js` for ESM output)
4747
- **Named exports only** — No default exports
4848
- **No `any` types** — Full TypeScript strict mode

0 commit comments

Comments
 (0)