|
| 1 | +Guidance for AI coding agents (Copilot, Cursor, Aider, Claude, etc.) working in this repository. Human readers are welcome, but this file is written for tools. |
| 2 | + |
| 3 | +### Repository purpose |
| 4 | + |
| 5 | +This repo hosts Stream’s React Chat SDK. It provides UI component. |
| 6 | + |
| 7 | +Agents should prioritize backwards compatibility, API stability, and high test coverage when changing code. |
| 8 | + |
| 9 | +### Tech & toolchain |
| 10 | + |
| 11 | +- Language: React (Typescript) |
| 12 | +- Primary runtime: Node (use the version in .nvmrc via nvm use) |
| 13 | +- Testing: Unit/integration: Jest (+ React Testing Library). |
| 14 | +- CI: GitHub Actions (assume PR validation on build + tests + lint) |
| 15 | +- Lint/format: ESLint + Prettier (configs in repo root) |
| 16 | +- Styles: Import Stream styles and override via CSS layers as described in README (don’t edit compiled CSS) |
| 17 | +- Release discipline: Conventional Commits + automated release tooling (see commitlint/semantic-release configs). |
| 18 | + |
| 19 | +### Project layout (high level) |
| 20 | + |
| 21 | +- src/ — Components, hooks, contexts, styles, and utilities (library source). |
| 22 | +- scripts/ - Scripts run during the build process |
| 23 | +- e2e/ — Playwright specs. |
| 24 | +- examples/ — Example apps/snippets. |
| 25 | +- developers/ — Dev notes & scripts. |
| 26 | + |
| 27 | +Use the closest folder’s patterns and conventions when editing. |
| 28 | + |
| 29 | +### Configurations |
| 30 | + |
| 31 | +Root configs: |
| 32 | + |
| 33 | +- .babelrc.js |
| 34 | +- .gitignore |
| 35 | +- .lintstagedrc.fix.json |
| 36 | +- .lintstagedrc.json |
| 37 | +- .nvmrc |
| 38 | +- .prettierignore |
| 39 | +- .prettierrc |
| 40 | +- .releaserc.json |
| 41 | +- babel.config.js |
| 42 | +- codecov.yml |
| 43 | +- commitlint.config.mjs |
| 44 | +- eslint.config.mjs, |
| 45 | +- i18next-parser.config.js |
| 46 | +- jest.config.js |
| 47 | +- jest.config.js |
| 48 | +- playwright.config.ts |
| 49 | +- tsconfig.json |
| 50 | + |
| 51 | +Respect any repo-specific rules. Do not suppress rules broadly; justify and scope exceptions. |
| 52 | + |
| 53 | +### Runbook (commands) |
| 54 | + |
| 55 | +1. Install dependencies: yarn install |
| 56 | +2. Build: yarn build |
| 57 | +3. Typecheck: yarn types |
| 58 | +4. Lint: yarn lint |
| 59 | +5. Fix lint issues: yarn lint-fix |
| 60 | +6. Unit tests: yarn test |
| 61 | + |
| 62 | +### General rules |
| 63 | + |
| 64 | +#### Linting & formatting |
| 65 | + |
| 66 | +- Make sure the eslint and prettier configurations are followed. Run before committing: |
| 67 | + |
| 68 | +``` |
| 69 | +yarn lint-fix |
| 70 | +``` |
| 71 | + |
| 72 | +#### Commit / PR conventions |
| 73 | + |
| 74 | +- Keep PRs small and focused; include tests. |
| 75 | +- Follow the project’s “zero warnings” policy—fix new warnings and avoid introducing any. |
| 76 | +- For UI changes, attach comparison screenshots (before/after) where feasible. |
| 77 | +- Ensure public API changes include docs. |
| 78 | + |
| 79 | +#### Testing policy |
| 80 | + |
| 81 | +Add/extend tests in the matching module’s `__tests__`/ folder. |
| 82 | + |
| 83 | +Cover: |
| 84 | + |
| 85 | +- React components |
| 86 | +- React hooks |
| 87 | +- Utility functions |
| 88 | +- Use fakes/mocks from the test helpers provided by the repo when possible. |
| 89 | + |
| 90 | +#### Docs & samples |
| 91 | + |
| 92 | +- When altering public API, update inline docs and any affected guide pages in the docs site where this repo is the source of truth. |
| 93 | +- Keep sample/snippet code compilable. |
| 94 | + |
| 95 | +#### Security & credentials |
| 96 | + |
| 97 | +- Never commit API keys or customer data. |
| 98 | +- Example code must use obvious placeholders (e.g., YOUR_STREAM_KEY). |
| 99 | +- If you add scripts, ensure they fail closed on missing env vars. |
| 100 | + |
| 101 | +#### When in doubt |
| 102 | + |
| 103 | +- Mirror existing patterns in the nearest module. |
| 104 | +- Prefer additive changes; avoid breaking public APIs. |
| 105 | +- Ask maintainers (CODEOWNERS) through PR mentions for modules you touch. |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +Quick agent checklist (per commit) |
| 110 | + |
| 111 | +- Build the src |
| 112 | +- Run all tests and ensure green |
| 113 | +- Run lint commands |
| 114 | +- Update docs if public API changed |
| 115 | +- Add/adjust tests |
| 116 | +- No new warnings |
| 117 | + |
| 118 | +End of machine guidance. Edit this file to refine agent behavior over time; keep human-facing details in README.md and docs. |
0 commit comments