Skip to content

Commit c2287de

Browse files
authored
chore: agent instructions (#1945)
Instructions for various coding agents.
1 parent 2797909 commit c2287de

File tree

1 file changed

+197
-0
lines changed

1 file changed

+197
-0
lines changed

AGENTS.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# Guidance for AI coding agents
2+
3+
File purpose: operational rules for automated or assisted code changes. Human-facing conceptual docs belong in `README.md` or the docs site.
4+
5+
## Repository purpose
6+
7+
Stream Video SDKs for:
8+
9+
- React
10+
- React Native
11+
- Plain JavaScript (core client)
12+
13+
Goals: API stability, backward compatibility, predictable releases, strong test coverage, accessibility, and performance discipline.
14+
15+
## Tech & toolchain
16+
17+
- Languages: TypeScript, React (web + native)
18+
- Runtime: Node (use `nvm use` with `.nvmrc`)
19+
- Package manager: Yarn (workspaces)
20+
- Testing: Vitest (unit/integration), Playwright (E2E)
21+
- Lint/Format: ESLint + Prettier
22+
- Build: Package-local build scripts (composed via root)
23+
- Release: Conventional Commits -> automated versioning/publishing
24+
- Platforms:
25+
- React: Web
26+
- React Native: iOS and Android
27+
28+
## Environment setup
29+
30+
1. `nvm use`
31+
2. `yarn install`
32+
3. (Optional) Verify: `node -v` matches `.nvmrc`
33+
4. Run initial full build: `yarn build:all`
34+
5. Run tests: `yarn test:ci:all`
35+
36+
## Project layout (high-level)
37+
38+
- `packages/`
39+
- `react-sdk/`
40+
- `react-native-sdk/`
41+
- `client/` (core, no UI)
42+
- `sample-apps/`
43+
- `react/`
44+
- `react-native/`
45+
- `client/`
46+
- Config roots: linting, tsconfig, playwright, babel
47+
- Do not edit generated output (`dist/`, build artifacts)
48+
49+
## Core commands (Runbook)
50+
51+
| Action | Command |
52+
| ----------------------------------- | ------------------------------------------ |
53+
| Install deps | `yarn install` |
54+
| Full build | `yarn build:all` |
55+
| Watch (if available) | `yarn dev` or `yarn start` (add if absent) |
56+
| Lint | `yarn lint:all` |
57+
| Fix lint (if separate) | `yarn lint:all --fix` |
58+
| Unit/Integration tests (CI profile) | `yarn test:ci:all` |
59+
| Local fast tests | `yarn test` |
60+
| E2E (Playwright) | `yarn test:e2e` |
61+
| Coverage | `yarn test:coverage` |
62+
| Clean | `yarn clean:all` |
63+
64+
## API design principles
65+
66+
- Semantic versioning
67+
- Use `@deprecated` JSDoc with replacement guidance
68+
- Provide migration docs for breaking changes
69+
- Avoid breaking changes; prefer additive evolution
70+
- Public surfaces: explicit TypeScript types/interfaces
71+
- Consistent naming: `camelCase` for functions/properties, `PascalCase` for components/types
72+
73+
### Deprecation lifecycle
74+
75+
1. Mark with `@deprecated` + rationale + alternative.
76+
2. Maintain for at least one minor release unless security-critical.
77+
3. Add to migration documentation.
78+
4. Remove only in next major.
79+
80+
## Performance guidelines
81+
82+
- Minimize re-renders (memoization, stable refs)
83+
- Use `React.memo` / `useCallback` / `useMemo` when profiling justifies
84+
- Clean up side effects (`AbortController` for network calls)
85+
- Monitor bundle size; justify increases > 2% per package
86+
- Prefer lazy loading for optional heavy modules
87+
- Avoid unnecessary large dependency additions
88+
89+
## Accessibility (a11y)
90+
91+
- All interactive elements keyboard accessible
92+
- Provide ARIA roles/labels where semantic tags insufficient
93+
- Maintain color contrast (WCAG AA)
94+
- Do not convey state by color alone
95+
- Announce dynamic content changes (ARIA live regions if needed)
96+
97+
## Error & logging policy
98+
99+
- Public API: throw descriptive errors or return typed error results (consistent with existing patterns)
100+
- No console noise in production builds
101+
- Internal debug logging gated behind env flag (if present)
102+
- Never leak credentials/user data in errors
103+
104+
## Concurrency & async
105+
106+
- Cancel stale async operations (media, network) when components unmount
107+
- Use `AbortController` for fetch-like APIs
108+
- Avoid race conditions: check instance IDs / timestamps before state updates
109+
110+
## Testing strategy
111+
112+
- Unit: pure functions, small components
113+
- Integration: component-tree interactions, state flows
114+
- React Native: target minimal smoke + platform logic (avoid flakiness)
115+
- E2E: critical user journeys (Playwright)
116+
- Mocks/fakes: prefer shared test helpers
117+
- Coverage target: maintain or improve existing percentage (fail PR if global coverage drops)
118+
- File naming: `*.test.ts` / `*.spec.ts(x)`
119+
- Add tests for: new public API, bug fixes (regression test), performance-sensitive utilities
120+
121+
## CI expectations
122+
123+
- Mandatory: build, lint, type check, unit/integration tests, (optionally) E2E smoke
124+
- Node versions: those listed in matrix (see workflow YAML)
125+
- Failing or flaky tests: fix or quarantine with justification PR comment (temporary)
126+
- Zero new warnings
127+
128+
## Release workflow (high-level)
129+
130+
1. Conventional Commit messages on PR merge
131+
2. Release automation aggregates commits
132+
3. Version bump + changelog + tag
133+
4. Publish to registry
134+
5. Deprecations noted in CHANGELOG
135+
6. Ensure docs updated prior to publishing breaking changes
136+
137+
## Dependency policy
138+
139+
- Avoid adding large deps without justification (size, maintenance)
140+
- Prefer existing utility packages
141+
- Run `yarn audit` (or equivalent) if adding security-impacting deps
142+
- Keep upgrades separate from feature changes when possible
143+
144+
## Samples & docs
145+
146+
- New public feature: update at least one sample app
147+
- Breaking changes: provide migration snippet
148+
- Keep code snippets compilable
149+
- Use placeholder keys (`YOUR_STREAM_KEY`)
150+
151+
## React Native specifics
152+
153+
- Clear Metro cache if module resolution issues: `yarn react-native start --reset-cache`
154+
- Test on iOS + Android for native module or platform-specific UI changes
155+
- Avoid unguarded web-only APIs in shared code
156+
157+
## Linting & formatting
158+
159+
- Run `yarn lint:all` before commit
160+
- Narrowly scope `eslint-disable` with inline comments and rationale
161+
- No broad rule disabling
162+
163+
## Commit / PR conventions
164+
165+
- Small, focused PRs
166+
- Include tests for changes
167+
- Screenshot or video for UI changes (before/after)
168+
- Label breaking changes clearly in description
169+
- Document public API changes
170+
171+
## Security
172+
173+
- No credentials or real user data
174+
- Use placeholders in examples
175+
- Scripts must error on missing critical env vars
176+
- Avoid introducing unmaintained dependencies
177+
178+
## Prohibited edits
179+
180+
- Do not edit build artifacts (`dist/`, generated types)
181+
- Do not bypass lint/type errors with force merges
182+
183+
## Quick agent checklist (per commit)
184+
185+
- Build succeeds
186+
- Lint clean
187+
- Type check clean
188+
- Tests (unit/integration) green
189+
- Coverage not reduced
190+
- Public API docs updated if changed
191+
- Samples updated if feature surfaced
192+
- No new warnings
193+
- No generated files modified
194+
195+
---
196+
197+
Refine this file iteratively for agent clarity; keep human-facing explanations in docs site / `README.md`.

0 commit comments

Comments
 (0)