Tool-agnostic project conventions for AI coding assistants. For Claude Code-specific instructions, see CLAUDE.md.
React utility hooks/components library. Two published packages and an agent plugin:
react-simplikit(packages/react-simplikit) — React hooks, components and utils@react-simplikit/codemods(packages/codemods) — bin-only CLI that runs upgrade codemods on consumer codebases (mobile-to-roottoday)packages/plugin— agent skills for Claude Code, Codex and skills.sh. Nopackage.json, so it is neither a workspace nor on npm.yarn skill:genregeneratesskills/react-simplikitfrom the public exports andyarn test:skillfails CI when the committed copy drifts;skills/react-simplikit-codemodis hand-written
Layer dependency is unidirectional — no upward or circular imports:
components → hooks → utils → _internal
- Components may use hooks, utils, _internal
- Hooks may use utils, _internal
- Utils may use _internal only
Each hook/component/util lives in its own folder with co-located docs:
src/hooks/useHookName/
├── index.ts # Re-export
├── useHookName.ts # Implementation
├── useHookName.test.ts # Tests (`.spec.ts` in older folders)
├── useHookName.ssr.test.ts # SSR safety tests
├── useHookName.md # English docs
└── ko/
└── useHookName.md # Korean docs
typeoverinterface— Always usetypefor type aliases- Named functions in useEffect —
useEffect(function handleResize() { ... }, [])not arrow functions - No implicit boolean coercion —
if (value)→if (value != null)(enforced bystrict-boolean-expressions) - Import extensions — Use
.ts/.tsxextensions in source imports (tsdown rewrites them to.mjs/.cjsin the output) - Named exports only — No default exports
- No
anyin implementation — Full TypeScript strict mode, and lint rejectsany. For the parameter list of a function the caller passes in, useCallerTypedArgsfromsrc/_internal/types.ts - Zero runtime dependencies
Use == null for nullish checks — checks both null and undefined:
// ✅ Good
if (ref == null) {
continue;
}
items.filter(item => item != null);
// ✅ Use !== undefined only when null/undefined distinction matters
const controlled = valueProp !== undefined;Prefer early returns (guard clauses) over nested if-else:
// ✅ Good — guard clause
function process(value: string | null) {
if (value == null) {
return DEFAULT;
}
return transform(value);
}
// ❌ Bad — nested if-else
function process(value: string | null) {
if (value != null) {
return transform(value);
} else {
return DEFAULT;
}
}Function declarations use function keyword, arrow functions only for short inline callbacks:
// ✅ Good — function keyword for declarations
function toggle(state: boolean) {
return !state;
}
// ✅ Good — arrow for inline callbacks
items.filter(item => item != null);
// ❌ Bad — arrow for function declarations
const toggle = (state: boolean) => !state;All hooks/utils accessing browser APIs must be SSR-safe:
const [state, setState] = useState(FIXED_INITIAL_VALUE);
useEffect(function syncBrowserState() {
if (isServer()) return;
setState(getBrowserAPI());
}, []);Never initialize state with browser API calls (causes hydration mismatch).
- Single value:
useDebounce<T>(value, delay): T - Tuple (2 items):
useToggle(init): [boolean, () => void] - Object (3+ items):
usePagination(): { page, nextPage, prevPage } - Object also when the shape is expected to grow:
useKeyboardHeight(): { keyboardHeight }
- 100% coverage mandatory — Enforced by Vitest coverage threshold
- SSR tests required — All hooks accessing browser APIs need
.ssr.test.ts - useEffect cleanup — Always return cleanup in useEffect to remove listeners
- SSR test pattern:
import { renderHookSSR } from '../../_internal/test-utils/renderHookSSR.tsx'; it('is safe on server side rendering', () => { const result = renderHookSSR.serverOnly(() => useHookName()); expect(result.current).toBeDefined(); });
- Throttle subscriptions at ~16ms (60fps)
- Deduplicate to skip unchanged updates
- Use
startTransitionfor non-urgent state updates (React 18+)
- Locales: English source plus the locales registered in
.vitepress/locales.mts(currently ko, ja, zh-Hans, es), co-located with the source (useX.md,<locale>/useX.md; guides underdocs/<locale>/) - JSDoc required: Every public API must have
@description+@example+@param+@returns - English API docs are generated:
yarn docs:gen <name>turns the JSDoc into<name>.md. Do not hand-edit the English API.md - Translations are written with your local AI harness: draft from the English source, then review with
.claude/agents/agent-translation-reviewer.md(glossary and rules inside). Nothing in CI translates - Keep translations in sync: a PR that changes an English doc updates every translated counterpart. Untranslated pages fall back to English with a banner
Format: <type>(<scope>): <description>
Types: feat, fix, docs, chore, refactor, test
Scope: the hook, component, util or area the change touches (useToggle, docs, codemod, ci); omit when it spans the package
yarn build # Build all packages (tsdown)
yarn test # Run tests (Vitest)
yarn fix # Auto-fix lint + format
yarn typecheck # Type check (tsc --noEmit)