协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
agents-md【开发与工程】Write effective AGENTS.md files that give coding agents the context they need to work in a repository. Use when creating a new AGENTS.md, improving an existing one, setting up a repo for AI coding agents, or onboarding agents to a codebase. Triggers on: "write AGENTS.md", "create AGENTS.md", "agent instructions", "set up repo for agents", "configure …
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
AGENTS.md is a README for coding agents. It lives at the repo root and tells agents how to build, test, lint, navigate, and contribute to the project. Based on the agents.md open format (https://agents.md) and lessons from OpenAI's harness engineering approach.
Keep AGENTS.md short (~100-150 lines). It's a table of contents, not an encyclopedia.
The "one big instruction file" approach fails because:
Point to deeper docs elsewhere. The agent starts with AGENTS.md and drills into references as needed.
The most immediately useful section. Concrete commands, not prose.
## Commands
- Install: `npm install`
- Dev server: `npm run dev`
- Test single file: `npx vitest run path/to/test.ts`
- Test all: `npm test`
- Lint: `npm run lint`
- Format: `npm run format`
- Type check: `npm run typecheck`
Include any prerequisites or non-obvious setup. If the project uses Docker, Nix, or a custom build system, say so here.
Key paths and what lives where. Keep it high-level — 1 line per directory.
## Repository Structure
- `src/api/` — HTTP API layer, routes and validation
- `src/store/` — Database access, all SQL lives here
- `src/worker/` — Background job processing
- `src/types/` — Shared domain types
- `tests/` — Test files mirror source structure
- `docs/` — Architecture and design documentation
For the full treatment of how to write an architecture codemap with boundaries
and invariants, see the architecture-md skill.
What can depend on what. What's deliberately absent. These are the rules agents violate most often without explicit guidance.
## Architecture Boundaries
- API layer never accesses the database directly — always goes through `src/store/`
- `src/types/` has zero dependencies on other source modules
- Workers communicate via the store interface, never import API code
- No circular dependencies between top-level modules
Don't list things the agent already knows (like "use const over let"). List only project-specific conventions the agent couldn't infer from reading the code.
## Coding Standards
- Strict TypeScript — no `any`, no `as` casts except in test files
- Errors: use `Result<T, E>` pattern from `src/types/result.ts`, not thrown exceptions
- Logging: always use structured logger from `src/logger.ts`, never `console.log`
- Naming: database columns are snake_case, TypeScript properties are camelCase
How to run tests, where they live, patterns to follow, what to cover.
## Testing
- Tests live next to source: `src/foo.ts` -> `src/foo.test.ts`
- Use `describe`/`it` blocks, not `test()`
- Mock external services, never hit real APIs in tests
- New features require tests — cover success, failure, and edge cases
- Run relevant tests before submitting: `npx vitest run src/path/`
## Commits & PRs
- Conventional commits: `feat:`, `fix:`, `refactor:`, `test:`, `docs:`
- PR title format: `type(scope): description`
- Run `npm run lint && npm test` before committing
- Keep PRs focused — one logical change per PR
Explicit guardrails prevent costly mistakes.
## Boundaries
- **Never:** commit secrets, credentials, or tokens
- **Never:** use destructive git operations (force push, hard reset) without asking
- **Never:** edit generated files by hand when a generation workflow exists
- **Ask first:** large cross-module refactors, new dependencies, migration changes
Pointers to deeper documentation. This is where the "table of contents" pattern pays off — keep AGENTS.md lean, point elsewhere for depth.
## References
- Architecture: see `ARCHITECTURE.md`
- API docs: see `docs/api-reference.md`
- Design decisions: see `docs/design-docs/`
- Deployment: see `docs/deployment.md`
Root AGENTS.md for global rules. Nested AGENTS.md per package for package-specific instructions. The closest file to the edited code wins.
AGENTS.md # global: commit conventions, CI, shared tooling
packages/api/AGENTS.md # API-specific: routes, middleware, auth patterns
packages/worker/AGENTS.md # worker-specific: job patterns, retry behavior
packages/shared/AGENTS.md # shared lib: no side effects, pure functions only
Keep nested files focused on what's different about that package. Don't repeat global rules — the agent reads both the nearest file and the root.
eslint catches it, don't list it.Before finishing, verify: