--- url: https://react-simplikit.slash.page/core/ai-integration.md description: Use react-simplikit with AI coding agents --- # AI Integration react-simplikit ships a few things that let an AI coding agent (Claude Code, Codex, Cursor and others) find the right hook instead of hand-writing it. ## Agent skill The `react-simplikit` skill is a short catalog of every hook, component and util with a one-line description, plus rules about imports and SSR. Once installed, the agent consults it before writing debounce, throttle, click-outside, keyboard-avoidance and similar logic, and reads the bundled reference page before using an entry. ::: code-group ```sh [skills.sh] npx skills add toss/react-simplikit --skill react-simplikit ``` ```sh [Claude Code] claude plugin marketplace add https://github.com/toss/react-simplikit --sparse .claude-plugin packages/plugin claude plugin install react-simplikit@react-simplikit ``` ```sh [Codex] codex plugin marketplace add https://github.com/toss/react-simplikit # then install "react-simplikit" from the plugin UI ``` ::: The skill is generated from these documentation pages, so it stays in sync with the library. Its source lives in [`packages/plugin`](https://github.com/toss/react-simplikit/tree/main/packages/plugin). ## llms.txt The documentation is also published in the formats agents read directly: * [`/llms.txt`](https://react-simplikit.slash.page/llms.txt) — an index of every page with a one-line summary * [`/llms-full.txt`](https://react-simplikit.slash.page/llms-full.txt) — the whole documentation in one file * Any page with a `.md` suffix returns raw Markdown, for example [`/core/hooks/useDebounce.md`](https://react-simplikit.slash.page/core/hooks/useDebounce.md) ## Context7 react-simplikit is indexed on [Context7](https://context7.com/toss/react-simplikit) as `/toss/react-simplikit`. Agents with the Context7 MCP server can query the documentation from there without any setup on your side. --- --- url: https://react-simplikit.slash.page/core/utils/buildContext.md --- # buildContext `buildContext` is a helper function that reduces repetitive code when defining React Context. ## Interface ```ts function buildContext( contextName: string, defaultContextValues: ContextValuesType ): [ Provider: (props: ProviderProps) => JSX.Element, useContext: () => ContextValuesType, ]; ``` ### Parameters ### Return Value ## Example ```tsx const [Provider, useContext] = buildContext<{ title: string }>( 'TestContext', null ); function Inner() { const { title } = useContext(); return
{title}
; } function Page() { return ( ); } ``` --- --- url: https://react-simplikit.slash.page/core/contributing.md --- # Contributing to react-simplikit `react-simplikit` is designed to encourage contributions from anyone. If you'd like to contribute, please follow the guide below. ## Package Scope `react-simplikit` focuses on **platform-independent hooks, components, and utilities** that work across all JavaScript environments (browser, server, React Native, etc.). Before contributing, check which package your implementation belongs to: | Package | Scope | Examples | | ------------------------------- | -------------------------------------- | ------------------------------------------------------------ | | `react-simplikit` | Platform-independent pure state/logic | `useToggle`, `useAsyncEffect`, `useLoading` | | Mobile utilities (`src/mobile`) | Solving mobile web-specific challenges | `useAvoidKeyboard`, `useBodyScrollLock`, `useVisualViewport` | ::: tip The mobile package is **not** for all browser API-dependent hooks. It specifically targets **problems encountered in mobile web environments** (viewport management, keyboard handling, layout issues on iOS Safari and Android Chrome). For example, a keyboard shortcut hook uses browser APIs but doesn't belong in the mobile package. ::: ## Implementation Contribution When contributing implementations, add them to the appropriate directory based on their type (`components`, `hooks`, or `utils`). Each implementation must include the following elements: * **Implementation** * **Test Code** * **JSDoc** ::: tip **Do I need to write documentation?** No, you don't need to write documentation separately. Instead, please write detailed JSDoc comments, then run `yarn docs:gen ` to generate the English documentation from them and commit the result with your PR. Translations are maintained separately; until one exists, the page is shown in English with a notice. ::: ### Writing Implementations You must follow `react-simplikit`'s [Design Principles](./design-principles.md). We don't provide implementations that depend on specific libraries or are tightly coupled with React's lifecycle. Please write implementations that adhere to these design principles. ### Writing JSDoc All implementations must include [JSDoc](https://jsdoc.app/) comments. These provide hints when using the implementation and play a crucial role in generating documentation. JSDoc comments must include `@description` and `@example`, and if there are parameters or return values, they should include `@param` and `@returns`. ::: details JSDoc writing rules must be followed for accurate documentation generation. If JSDoc validation fails, CI might fail. * JSDoc must be written in English. * `@description`: A required tag that clearly explains the implementation's functionality or role. * `@example`: A required tag that shows example code demonstrating how to use the implementation. * `@param`: Write the parameter's name and description. Must be included if the implementation has parameters. * For required parameters: `@param {} - ` * For optional parameters: `@param {} [] - ` * For object parameters, both the object itself and its properties need `@param` tags. * If you want to write a list under a description, use `--` instead of `-`. ```ts type Props = { name: string; age: number; nickname?: string; company: { name: string; address?: string; }; paymentMethod?: { type: 'card' | 'account'; number?: string; }; }; /** * @param {string} name - Name of the user. * @param {number} age - Age of the user. * @param {string} [nickname] - Nickname of the user. * @param {Object} company - Company information of the user. * @param {string} company.name - Name of the company. * @param {string} [company.address] - Address of the company. * @param {Object} [paymentMethod] - Payment information of the user. * @param {string} [paymentMethod.type] - Payment method. * @param {string} [paymentMethod.number] - Card or account number. * -- Card or account number without `-`. * -- If the number is a card number, it should be 15 or 16 digits. */ ``` This JSDoc will be converted into the following documentation. * `@returns`: Write the return value's name and description. Must be included if the implementation has return values. * Format: `@returns {} ` * For object or tuple return values, include descriptions for each member. * If additional details are needed for each member, please use `:`. ```ts type ReturnValue = [Object, () => void]; /** * @returns {[Object, () => void]} A tuple containing: * - obj `Object` - An object containing: * : label `string` - The label of the input. * : value `string` - The value of the input. * - onChange `() => void` - A function to update the value. */ ``` This JSDoc will be converted into the following documentation. Object-type return values can be written in a similar way. ```ts type ReturnValue = { value: string; onChange: () => void }; /** * @returns {Object} An object containing: * - value `string` - The value of the input. * - onChange `() => void` - A function to update the value. */ ``` This JSDoc will be converted into the following documentation. ::: ### Writing Test Code All implementations must include test code, written with the same name as the implementation. Test coverage must always reach 100%. Use the following command to verify coverage: ```bash yarn test:coverage ``` ::: details Please verify safe operation in SSR environments All `react-simplikit` implementations use special rendering functions to verify safe operation in SSR environments. * Component Testing ```tsx it('is safe on server side rendering', () => { // renderSSR.serverOnly is a method that renders the component in the server environment. // In this environment, hooks like useEffect are not executed, and objects like window or document are not available, causing errors. renderSSR.serverOnly(() => (
Test Content
)); expect(screen.getByText('Test Content')).toBeInTheDocument(); }); it('should render children correctly', async () => { // renderSSR is a method that renders the component in the client environment. // However, if the HTML rendered on the server and the HTML rendered on the client are different, hydration mismatch errors will occur. await renderSSR(() => (
Test Content
)); expect(screen.getByText('Test Content')).toBeInTheDocument(); }); it('should hydration mismatch error occurred', async () => { // This test code will fail due to a hydration mismatch error. await renderSSR(() => (
Test Content
{Math.random()}
)); expect(screen.getByText('Test Content')).toBeInTheDocument(); }); ``` * Hook Testing ```ts it('is safe on server side rendering', () => { // renderHookSSR.serverOnly is a method that renders the hook in the server environment. // In this environment, hooks like useEffect are not executed, and objects like window or document are not available, causing errors. const result = renderHookSSR.serverOnly(() => useToggle(true)); const [bool] = result.current; expect(bool).toBe(true); }); it('should initialize with the default value true', async () => { const { result } = await renderHookSSR(() => useToggle(true)); const [bool] = result.current; expect(bool).toBe(true); }); ``` ::: ### Creating a Changeset When your code changes affect the package, you need to create a changeset. Changesets are a tool that automates version management and changelog generation. #### How to Create a Changeset 1. After implementing your changes, run the following command: ```bash yarn changeset ``` 2. Select the type of change: * `patch`: Bug fixes or minor changes * `minor`: New features (maintaining backward compatibility) * `major`: Breaking changes (breaking backward compatibility) 3. Write a brief summary of your changes. ::: tip Both packages are currently in the `0.0.x` stage. During this phase, most changes should use `patch`. If you're unsure about the version type, please discuss with the maintainers. ::: 4. Commit the generated changeset file with your PR. ::: tip Changeset files are created in the `.changeset` folder and must be committed with your PR. When the PR is merged, the version will be automatically updated and a changelog will be generated. ::: ### Release When changes are merged into the `main` branch, the release process happens automatically: 1. When a PR is merged into the `main` branch, GitHub Actions will run. 2. If there are changesets, a version update PR will be automatically created. 3. When the version update PR is merged, the new version will be published to npm. You can view the release results in [GitHub Actions](https://github.com/toss/react-simplikit/actions). ## Documentation Contribution There are no specific conditions for contributing to documentation. If you find incorrect information, poor translations, or have additional content to add, feel free to make edits. Please write documentation clearly and concisely from the reader's perspective. ## Scaffolding There's a command that creates the minimum skeleton for contributions. Use the following command to create an implementation folder with a basic structure: ```bash yarn run scaffold --type ``` * `type`: Implementation type, must be one of `component`, `hook`, or `util`. * `name`: Name of the implementation. ### Example ```bash yarn run scaffold Button --type component ``` This command creates three files in the `src/components/Button` folder: ::: code-group ```tsx [Button.tsx] /** * @description * * * @param {} - * @param {} [] - * * @returns {} * - `` - * * @example * */ export function Button() { // TODO: Implement Button } ``` ```tsx [Button.spec.ts] import { describe, expect, it } from 'vitest'; import { renderSSR } from '../../_internal/test-utils/renderSSR.tsx'; import { Button } from './Button.tsx'; describe('Button', () => { it('is safe on server side rendering', async () => { const result = renderSSR.serverOnly(() => ); } ``` ### Rendering Arrays with Specific Separators \