TypeScript 单体仓库:根目录 AGENTS.md 与 .cursor/rules/monorepo.mdc
在 pnpm / npm / yarn workspace 里用 Cursor 写 TypeScript 的工程师。路径:AGENTS.md · .cursor/rules/monorepo.mdc
不是 Roo / Cline 模版。本站不托管安装包。订哪档去 /compare。
把下面两个文件放到仓库根目录。路径按 Cursor 字面量:AGENTS.md 与 .cursor/rules/monorepo.mdc。
先投下规则,再去 /compare 决定订哪档。本页不是 Roo / Cline / Continue / ChatGPT 模版;不要改成 .roo 或 .clinerules。本站不托管 Cursor 安装包,装桌面走 /downloads。
AGENTS.md# AGENTS.md
This repository is a TypeScript monorepo. Read this file before editing.
## Layout
- `apps/` — deployable applications. Each app owns its `package.json`, tsconfig, and runtime.
- `packages/` — shared libraries consumed via the workspace protocol already used here.
- Do not add a new top-level code folder when the change belongs in `apps/` or `packages/`.
## Package manager
- Honor the lockfile already in the repo (`pnpm-lock.yaml`, `package-lock.json`, or `yarn.lock`).
- Install with the matching command: `pnpm install` / `npm install` / `yarn`.
- Do not add a new npm package unless the task requires it and no workspace package already covers it.
- Internal dependencies use the same workspace protocol as existing packages (`workspace:*` or `*`).
## TypeScript
- Keep existing `compilerOptions` (strictness, `module`, `paths`). Do not weaken `strict`.
- Shared types live in `packages/`. Do not copy type files between apps.
- Apps import a package's public exports only. Do not reach into another package's `src` internals unless that is already the local convention.
## Changes
- Scope the diff to the app or package named in the request.
- Do not drive-by refactor unrelated files.
- Match local naming, comment style, and test layout.
- After edits, run the nearest `typecheck` / `lint` / unit test for the touched package.
## Secrets
- Never commit API keys, tokens, or `.env` values.
- `.cursor/mcp.json` must not contain secrets; use the process environment instead.
## What this file is
Root agent contract picked up from the repository root. Glob-scoped Cursor rules live in `.cursor/rules/*.mdc`..cursor/rules/monorepo.mdc---
description: TypeScript monorepo — workspace protocol, package boundaries, no extra dependencies
globs: "{apps,packages}/**/*.{ts,tsx,js,jsx,json}"
alwaysApply: false
---
# Monorepo conventions
- Treat `apps/*` as deployable roots and `packages/*` as libraries.
- Do not import one app from another. Share code by extracting a package.
- Put a new dependency in the package that imports it, not the repo root, unless it is a root toolchain (TypeScript, ESLint, the test runner).
- Do not introduce a second package manager or a second lockfile.
- Path aliases (`@/` and similar) stay inside the owning app; do not assume they resolve in other packages.
- Wait for an explicit request before creating a new workspace package.
- Keep generated output (`dist`, `.next`, `coverage`) out of commits.
- If a script needs the repo root, prefer `workspace` tooling over hard-coded absolute paths.