This is the canonical shared instruction file for coding agents working in this repository.
If another agent-specific file exists, it should import or defer to this file for shared repository guidance.
Egg is maintained as a pnpm monorepo.
packages/contains core framework packages and shared internals.plugins/contains optional Egg integrations.tools/contains developer tooling such as CLI packages.tegg/contains the tegg ecosystem.examples/contains sample applications.site/docs/contains the English and Chinese documentation site.- tests usually live beside packages under
test/, often with fixtures undertest/fixtures/.
pnpm installhydrates the workspace.pnpm run buildbuilds all packages.pnpm run testruns the main test suite.pnpm run lintruns linting.pnpm run typecheckruns TypeScript checking.- use filtered commands for focused work, for example
pnpm --filter=egg run testorpnpm --filter=site run dev.
- prefer existing repo patterns over inventing new ones
- prefer ESM and TypeScript-first changes where applicable
- keep file names lowercase with hyphens
- keep public API changes deliberate and documented
- use
oxfmtandoxlint --type-awareconventions already present in the repo
- run the most targeted tests that validate the touched area
- include regression coverage when changing loader, cluster, agent, HTTP, or process behavior
- use Angular-style commit messages such as
fix(loader): ensure middleware order - keep PR descriptions clear about motivation, scope, and test evidence
- review
SECURITY.mdbefore handling vulnerability-related work - do not commit secrets, credentials, or local-only URLs
- keep local Node.js and pnpm versions aligned with the repository configuration
This repository also maintains an LLM-owned wiki for durable project knowledge.
Use this three-layer model:
Raw sources are the source of truth.
They include:
- repository code under
packages/,plugins/,tools/,tegg/,examples/, andscripts/ - user-facing docs under
site/docs/ - root markdown files such as
README.md,README.zh-CN.md,CHANGELOG.md,CONTRIBUTING.md, andSECURITY.md - explicit external artifacts referenced by the user or task
- imported materials stored under
raw/
Rules:
- do not treat wiki summaries as authoritative when raw sources disagree
- do not rewrite raw sources unless the task requires it
- if you rely on an external source repeatedly, capture it in the wiki
The wiki lives under wiki/ and stores durable synthesized knowledge.
Shared workflow rules live here in AGENTS.md.
Agent-specific files should stay thin and point back to this file instead of duplicating the schema.
wiki/index.mdis the first wiki file to readwiki/log.mdis the append-only chronological logwiki/packages/holds package, plugin, tool, and subsystem pageswiki/concepts/holds architectural and cross-cutting pageswiki/workflows/holds repeatable procedureswiki/decisions/holds notable tradeoffs and decisionswiki/sources/holds summaries of major source documents or external materials
Use these page types:
packageconceptworkflowdecisionsource
Every substantive page should begin with frontmatter:
---
title: Short human-readable title
type: package|concept|workflow|decision|source
summary: One-line summary
source_files:
- path/or/url
updated_at: YYYY-MM-DD
status: seed|active|stale
---Use lowercase kebab-case filenames and keep one topic per page.
- every nontrivial wiki claim should be traceable to raw sources
- list major source paths in
source_files - label non-obvious synthesis as
Inference: - record conflicts explicitly instead of flattening them
- mark stale or unresolved claims when freshness is uncertain
wiki/index.md should:
- list durable pages by category
- give each page a one-line summary
- stay concise enough to scan quickly
wiki/log.md should record:
- ingestion of substantial new sources
- durable findings produced during a query
- material wiki refactors or lint passes
- code or docs changes that alter previously recorded understanding
Do not log trivial typo-only edits.
- Read
wiki/index.md. - Find existing pages that should absorb the new information.
- Create or update a
sourcepage if the source is substantial. - Update impacted wiki pages.
- Update
wiki/index.md. - Append to
wiki/log.mdif the wiki changed materially.
- Read
wiki/index.mdand relevant wiki pages first. - Use the wiki as the starting point, not the final authority.
- Read raw sources for verification, detail, or freshness.
- Write durable new findings back into the wiki.
- Update the log when the wiki changes materially.
Check the wiki for:
- orphan pages
- stale claims after code or docs changes
- duplicated concepts
- missing source references
- missing pages for frequently touched areas
- contradictions between pages
Prefer restructuring pages over making them longer.
Prioritize durable wiki coverage for:
packages/egg,packages/core,packages/utils, and other foundational packages- plugins under
plugins/ - tools under
tools/ tegg/- docs structure under
site/docs/ - loading, lifecycle, plugin model, testing, release, and docs-maintenance concepts
Update the wiki when a task materially changes:
- public APIs
- docs structure or contributor guidance
- package responsibilities
- architectural behavior
- repeated workflows used by contributors
- testing or release expectations
For code-only tasks, avoid wiki churn unless durable understanding changed.