These instructions guide the coding agent when making changes that affect the entire monorepo structure, shared packages, or cross-application boundaries. For application-specific changes, refer to the individual AGENTS.md files in apps/frontend or apps/backend.
This monorepo is composed of three main packages:
apps/frontend: The user-facing application built with React/TypeScript.apps/backend: The backend API/business logic layer built with NestJS/TypeScript.apps/shared: A dedicated package for reusable types, utilities, and constants used by both client and server.
The agent MUST consider the impact on both apps/frontend and apps/backend when making changes to:
apps/shared: Any change here requires checking for breaking changes in consumer applications.- API Contracts: Updates to DTOs or API endpoints in
apps/backendmust be reflected in the corresponding request/response types and service calls inapps/frontend.
This monorepo uses bun workspaces for package linking. The shared package (@github-research/shared) is linked via workspace resolution.
-
Root
package.jsondefines workspaces:{ "workspaces": ["apps/*"] } -
Consumer apps reference the shared package using
workspace:*:{ "dependencies": { "@github-research/shared": "workspace:*" } } -
Bun creates a symlink at
node_modules/@github-research/shared→../../apps/shared.
| ✅ DO | ❌ DON'T |
|---|---|
Use workspace:* in dependencies |
Add TypeScript references to tsconfig.json |
| Let TypeScript resolve via node_modules | Add paths aliases like "@github-research/shared": ["../shared/src"] |
Keep shared package as ESM-only (type: "module") |
Add dual CJS/ESM builds |
Ensure exports in shared package.json matches actual dist paths |
Use composite: true in shared tsconfig |
- Add types/functions to
apps/shared/src/ - Export from
apps/shared/src/index.ts - Run
bun run --cwd apps/shared buildto compile - Import in consumer apps:
import { MyType } from '@github-research/shared'
| Issue | Cause | Fix |
|---|---|---|
Cannot find module '@github-research/shared' |
Shared package not built | Run bun run --cwd apps/shared build |
Backend outputs to dist/backend/src/ |
TypeScript project references | Remove references from backend tsconfig |
| Path mismatch errors | exports paths don't match dist structure |
Ensure package.json exports match actual output |
The agent MUST execute the necessary build and quality checks immediately after completing a code modification.
- Build Check:
bun build
- Linting/Formatting:
bun lint --fix
⚠️ Ifbun buildorbun lintfails, the agent MUST attempt to fix the issues before considering the task complete.
- Feature-First Grouping: Organize code by feature, not by file type.
- Modularity: Keep files and modules small and focused on a single responsibility.
- Logic Extraction: Prefer extracting logic into separate, pure functions.
| Guideline | Backend (NestJS) | Frontend (React) |
|---|---|---|
| Exports | Use export class, export const, or export function |
Always use export const (named exports). Avoid export default |
| Functions | Standard methods; arrow functions for utilities | Prefer arrow functions for components, hooks, utilities |
| Immutability | Favor const |
Strictly favor const |
| Entity | Convention | Example |
|---|---|---|
| Types/Interfaces | PascalCase | ItemDTO, IAppConfig |
| API Resources | Plural Nouns | items, users |
| Actions/Methods | Verb + Noun (camelCase) | getItems, createItem |
| Variables/Functions | camelCase | isValid, calculateTotal |
- No
any: Use specific TypeScript types, generic types, orunknownfollowed by type narrowing. - Zod: Use Zod schemas for defining and validating data structures.
- API Boundaries: Mandatory validation at API boundaries.
- Shared Types: Always import types from
@github-research/sharedwhen available.
The agent must update the architecture documentation when making changes that affect a feature's architecture. Documentation lives in the docs/ folder.