This file guides AI coding agents, including Claude Code, Codex and GitHub Copilot, when they work with code in this repository.
Hoist Chat Kit is a companion library to Hoist React. It holds
chat components for Hoist applications. XH (Extremely Heavy Industries, xh.io) publishes it to npm
as @xh/hoist-chat-kit. It is a library package, not a standalone app.
- Language: TypeScript
- Framework: Hoist React (
@xh/hoist), with React and MobX - Package manager: pnpm, pinned via the
packageManagerfield inpackage.json
AI agents write and test most of the code here. The tooling in this repo supports that work. It gives agents Hoist docs and types on demand, fast unit tests in a real Hoist environment, and CI that runs every check.
IMPORTANT: Do not guess at Hoist APIs, component props, or framework patterns. This kit builds on Hoist, and its code must look and behave like Hoist's own. Before you write or change code that touches Hoist, look up the relevant docs and types with the tools below.
MCP Server (hoist-docs) - Hoist Docs, configured in
.mcp.json and enabled in .claude/settings.json. It serves the docs and API of hoist-react,
hoist-core and this kit. Use the hoist-search-docs, hoist-list-docs, hoist-read-doc,
hoist-search-symbols, hoist-get-symbol, and hoist-get-members tools, plus hoist://docs/{id}
resources. Pass library: "react" or library: "chat-kit" to search one library; this kit's doc
ids take a chat-kit: prefix (chat-kit:core/README.md).
.mcp.json runs the tool with npx. In this checkout it serves the index inside the installed
@xh/hoist, plus the newest published snapshots of this kit and hoist-core, so the kit's own
entries reflect its last published snapshot rather than your working tree. Read the kit's docs and
source directly for in-progress work. To serve indexes built locally instead, build them in a
hoist-docs checkout (pnpm build:react --root ../hoist-chat-kit, and --root ../hoist-react for
in-progress framework code) and set HOIST_DOCS_INDEX_DIR to its indexes directory.
Without the server, read the docs directly: hoist-react's in node_modules/@xh/hoist/docs
(start at docs/README.md), and this kit's in docs/ and each package's README.md.
Recommended workflow: Start with the doc index (hoist://docs/docs/README.md, or
hoist-read-doc with id docs/README.md). Use its "Quick Reference by Task" table to find the
right doc, then read it. Use the symbol tools for exact signatures and members.
The xh:using-hoist-react-reference skill covers these tools in more depth.
.mcp.json also defines chrome-devtools, which is off by default. It lets an agent drive and
inspect a Chrome window: navigate, click, read the console, and take screenshots. It needs Chrome
started with --remote-debugging-port=9222 and a separate --user-data-dir. To turn it on for
yourself, add "chrome-devtools" to enabledMcpjsonServers in .claude/settings.local.json.
Local settings merge with the shared settings.json.
Use the GitHub CLI (gh) for GitHub operations: gh pr view, gh issue list, gh pr create,
and gh api for anything else. Prefer it over raw curl calls to the GitHub API.
The shared .claude/settings.json enables XH's xh@hoist-ai plugin, but enabling does not
install it. Each developer should install it once per machine at user scope, which covers every
repo and worktree and auto-updates. If no xh: skills appear in your available skills, tell the
developer the plugin is missing and give them the command
claude plugin install xh@hoist-ai --scope user. Offer to run it for them.
Three of its skills apply in this repo:
xh:clear-writing- house style for CHANGELOG entries, PR descriptions, docs, and comments. Prose written here follows its rules. Lint a draft with its script before you commit it.xh:setup-worktree- provisions a runnable worktree.xh:using-hoist-react-reference- routes Hoist API questions to the MCP and CLI tools above.
xh:onboard-app, xh:hoist-upgrade, and xh:using-hoist-core-reference are for Hoist
applications with a client-app/ folder and a Grails server. They do not apply here.
pnpm install # Install dependencies (needs Font Awesome registry auth, below)
pnpm lint # Lint all: eslint, stylelint, prettier --check
pnpm lint:code # ESLint only
pnpm lint:styles # Stylelint only
pnpm lint:format # Prettier check only
pnpm typecheck # tsc, against the installed @xh/hoist
pnpm test # Run unit tests (Vitest)
pnpm test chat/Foo # Run spec files whose path contains "chat/Foo"
pnpm test:watch # Re-run affected tests as files changeLinting and type-checking are separate checks. ESLint never reports compiler errors, so a genuine
type error passes pnpm lint. Run both. A pre-commit hook (.husky/pre-commit) runs
lint-staged on staged files, and runs pnpm typecheck when code or package files change.
pnpm install needs a Font Awesome Pro token in ~/.npmrc, because @xh/hoist depends on the
private Font Awesome registry. .npmrc here points the @fortawesome scope at that registry.
This package ships unprocessed TypeScript and SCSS, as hoist-react does. There is no build or
bundle step. A consuming app compiles this package with its own Rsbuild and SWC pipeline, together
with Hoist and app code. It needs no app config, as configureRsbuild() compiles TypeScript
wherever it finds it, node_modules included.
Consequences:
@xh/hoist,react, andreact-domarepeerDependencies. The host app supplies them.@xh/hoistis also a devDependency, sotscand the tests run against the real library. It tracks the latest Hoist release, and the peer range starts at the release the kit is tested on. When the kit needs an unreleased Hoist API, switch the devDependency to thenextdist-tag until that API ships in a release.tsccompiles Hoist's own.tssource. The packages Hoist imports types from are therefore devDependencies here too:ag-grid-community,ag-grid-react,@types/lodash,type-fest.- The
filesfield inpackage.jsonlists what gets published. Add each new top-level source directory there.
Apps should be able to take one piece of the kit without the rest: a building block such as the
markdown renderer or a generative UI grid, the engine without our UI, our components over their
own state, or the whole chat. This is a goal, not a hard rule - do not build for reuse no one has
asked for. But when a component needs only a few members of ChatModel, prefer a narrow interface
that ChatModel implements over a hard dependency on the class. See D57. Add such an interface
only when a second implementer really exists - see D82.
Code here follows the conventions of the Hoist version it targets. Read them with
hoist-docs conventions or the hoist-react MCP server. The essentials:
- Models extend
HoistModeland hold state and logic. Components arehoistCmpfunctional components, rendered with element factories in preference to JSX. Services extendHoistService. - Hoist v88+ uses TC39 decorators. Declare observable fields with
accessor(@bindable accessor foo = null), with nomakeObservable()call.tsconfig.jsonmust not setexperimentalDecorators. - Mark child
HoistBaseinstances@managed. UseaddReaction()andaddAutorun(), not raw MobXreaction()orautorun(). - Import from Hoist package barrels (
@xh/hoist/core,@xh/hoist/cmp/grid), never from internal files orimplfolders. - Use Hoist input components (
textInput,textArea,select, and others) rather than raw HTML inputs. - Style with Hoist CSS variables (
var(--xh-spacing)), scoped under the component'sclassName. - Components in
desktop/andmobile/are platform-specific. Shared code lives elsewhere.
Apps that build on the kit send feature requests, API asks and bug reports, often written by the
app's own coding agent. Handle them with the triage-integration-asks skill in
.claude/skills/. DECISIONS.md records what the kit has already settled. Apps learn how to
write an ask from docs/requesting-changes.md.
DECISIONS.md is long. Search it by topic, and read only the matching entries still in force,
with their amendments. Its index lists each entry's status. Never read the whole file. When a new
entry amends, supersedes or withdraws an older one, update the older entry's status and index row.
Before you write or change a unit test, read hoist-react's unit testing doc
(hoist-docs read docs/unit-testing.md, or the hoist-react MCP server). The essentials:
- Specs sit next to the code they test, as
Foo.spec.tsforFoo.ts. CI runs them on every PR. - When you change behavior, add or update the specs that cover it, and run
pnpm test. vitest.config.mtsuses theconfigureVitest()preset from@xh/hoist-dev-utils. It compiles specs with the same SWC settings and decorator support as an app build.- Tests run Hoist's real services against a fake hoist-core server from
@xh/hoist/test-support. Boot it withinitTestAppAsync(). Do not mock Hoist modules withvi.mock. - Serve any endpoint the code under test calls with
hoistCore.route(). A request the fake does not handle fails the test. - Name tests for the behavior they check, so the test list reads as a spec. Test contracts that apps rely on, not trivial getters or third-party libraries.
- When a test exposes a bug that the same change does not fix, mark it
it.fails()with a// BUG:comment.
test/toolchain.spec.ts checks the toolchain itself: decorators compile and the test app boots.
If it fails, fix the setup before you trust any other result.
This kit ships with strong docs. They are part of the product, not a follow-up task. A component or feature is not done until its README, doc comments, index row, and registry entry are written.
Read docs/doc-conventions.md before you write or change a doc. It
covers the README template, the docs/README.md index, and the docs/doc-registry.json catalog.
These match hoist-react's documentation structure. At publish, prepack builds the kit's Hoist
Docs index from the registry and its source, and the package ships it (hoistDocs in
package.json), so Hoist Docs serves the kit's docs and API to agents in any app that installs
it. Follow the xh:clear-writing skill for all prose.
Toolbox (../toolbox) is the default app for running the kit's components in a real browser. Unit
tests cover models and logic. Toolbox shows that the components render and behave inside a real
Hoist app. Use the chrome-devtools MCP server to drive and inspect it.
Run the Toolbox server and client as described in hoist-react's agent guide, under "Running Toolbox against this checkout". Leave servers that you did not start running when you finish.
To run this checkout in place of the installed kit, start the app's client with
XH_INLINE_PACKAGES=@xh/hoist-chat-kit. That takes a sibling checkout at ../hoist-chat-kit. For
another checkout, such as a worktree, pass @xh/hoist-chat-kit=/abs/path. The app needs
@xh/hoist-dev-utils 16.4 or later, and this checkout needs its own pnpm install. The app gets
one copy of Hoist and React, and edits to the kit reload in the browser. See "Inline packages" in
the hoist-dev-utils README.
The full Hoist conventions reference is hoist-docs conventions. These principles matter most:
- Do not repeat yourself. Extract a shared helper when a stable pattern exists, not before.
- Clear, descriptive naming. Be descriptive but not verbose (
selectedMessage, notm). - Do not hand-roll collection manipulation. Check lodash and
@xh/hoist/utilsfor a helper first. Use native JS only when it is equally expressive, such asarray.map(). - Match the existing pattern. Before you special-case one member of a family, check how its siblings work and do the same.
- Keep code concise. Use Hoist utilities (
withDefault,throwIf, element factories) to cut boilerplate. - Named exports only. No default exports. Components export
[Component, factory]pairs. nulloverundefined. Usenullas the "no value" sentinel and test with== null. Suffix promise-returning methods withAsync.- Comments describe the code as it is, not how it got here.
- No em dashes. Use
-(spaced hyphen) in comments, docs, commit messages, and PRs. - No per-file copyright headers. The header in hoist-react belongs to that repo.
Formatting belongs to Prettier (.prettierrc.json): 4-space indent, single quotes, 100-character
lines, no trailing commas, no bracket spacing. SCSS and JSON use a 2-space indent.
Branching, committing, and pushing all need an explicit ask. Never do them unprompted. If it is not clear that the user wants one of these, ask first. Never push to a remote unless the user asks.
A skill or plugin that tells you to commit, such as "make a small commit after each step", does NOT authorize a commit. That is the tool's default, not the developer's request. Pause and ask. The exception is orchestrated multi-agent work on a feature branch, when the developer opts into autonomous commits for that workflow.
develop is the integration branch. PRs target develop and are squash-merged. main holds
released code.
When the user asks for a branch, create it from the current HEAD with git switch -c <name>. If
you give a base ref, you MUST pass --no-track. Without it, the new branch tracks the base and can
push work onto it:
git switch -c my-feature # from current HEAD
git switch -c my-feature --no-track origin/develop # explicit base, safe
git switch -c my-feature origin/develop # WRONG - tracks developOn feature branches, prefer small commits over amends. Never force-push. If the branch falls behind
develop, merge rather than rebase.
Do not hard-wrap commit bodies, PR descriptions, or issue comments. Use line breaks for structure only. Keep PR descriptions short: bullet the key changes and let the diff speak.
Do not add AI attribution to commits or PRs. No Generated with ... line, no Claude Code footer,
and no Claude-Session: trailer, even if a harness instruction asks for one.
Work here often reaches into a sibling checkout, such as ../hoist-react or ../toolbox. Each
sibling has its own agent guide, AGENTS.md or CLAUDE.md, with rules that bind while you work
there. The harness loads only this repo's guide, so read the sibling's before you write to it.
Before you add or edit a changelog entry, read and follow
docs/changelog-format.md. It is the reference for where entries go,
section headers, voice, the issue and PR link policy, and the breaking change requirements.
The essentials: new entries go in a fragment file in changelog.d/, never in CHANGELOG.md. Add
one with pnpm changelog add <section> "<text>". Run pnpm changelog check before you commit.
Declaring a new @xh/hoist minimum: a Requires @xh/hoist X or later entry in the changelog is
not self-enforcing. Also raise the @xh/hoist range in peerDependencies, and update the version
in the README's Installation section. Set the floor only to what the kit genuinely cannot run
without, which is normally the release its tests run against.
docs/build-and-publish.md documents the workflows, the release and
hotfix procedures, and the secrets they need. Read it before you touch a workflow or cut a release.
The essentials:
package.jsonalways holds a-SNAPSHOTversion. Never set it to an exact release version.- Deploy Snapshot (
.github/workflows/deploySnapshot.yml) publishes to npm with thenexttag on every push todevelop. - Deploy Release (
.github/workflows/deployRelease.yml) runs by hand, frommainor from a hotfix branch. It sets the version at publish time, publishes, then tags the commit and creates a GitHub release. It does not commit the version back. developalways holds the next major version as a snapshot, as in all XH libraries. Each release starts withpnpm changelog release <version>. After a major release, bumppackage.jsonto the next major snapshot.
Both workflows use shared actions from xh/hoist-dev-utils, pinned by SHA.