Documentation
AGENTS
Agent Guidelines for XControl
Agent Guidelines for XControl
Repository scope
These instructions apply to the entire repository. Create a more specific AGENTS.md
inside a subdirectory only when you need to override or augment the guidance below for
that subtree.
Project overview
XControl is a polyglot monorepo that ships:
- Multiple Go services (API server, account service, RAG server, supporting CLIs) under
the top-level Go module
xcontrol. - A Next.js dashboard (
dashboard/) implemented in TypeScript with Tailwind CSS and Vitest/Playwright tests. - CMS configuration, SQL migrations, deployment manifests, and documentation that are consumed by the services and UI.
General expectations
- Match the existing language of the file (English vs. Chinese or bilingual) and retain the bilingual structure when you touch documentation that already mixes both.
- Prefer structured logging (
log/slog) or existing helper utilities over rawfmt.Printlnin Go code. - Keep configuration files and generated assets deterministic. If you edit files under
config/,docs/cms/, orscripts/, mention any required regeneration steps in your commit message or PR description.
Go code (all directories except dashboard/)
- Format Go code with
gofmt(orgo fmt ./...) before committing. - Organize imports using
goimportsif available; otherwise maintain the existing standard library / third-party separation. - Run
go test ./...from the repository root (or a narrower package path) after changing Go files. Usemake testin submodules such asrag-server/when you need the module-specific workflow. - Keep configuration structs in sync with their YAML/JSON sources and update default values when you add new fields.
TypeScript / Next.js dashboard (dashboard/)
- Use
yarn(notnpmorpnpm). Install dependencies withyarn installand run scripts withyarn --cwd dashboard <script>. - Format code with the existing ESLint rules by running
yarn --cwd dashboard lint --fixwhen possible. Follow the 2-space indentation style and single-quote string literals you see in the current codebase. - Run
yarn --cwd dashboard lintand the relevant tests (yarn --cwd dashboard testand/oryarn --cwd dashboard test:e2e) when you touch dashboard code. - Avoid introducing runtime-only environment variables; prefer adding entries to
dashboard/config/runtime-service-config.yamlso that environments stay declarative.
Documentation and Markdown (docs/, README.md, etc.)
- Wrap prose at a reasonable width (~100 characters) and preserve existing heading hierarchies.
- When documenting commands or configuration, prefer fenced code blocks with explicit
language identifiers (e.g.,
bash,go,json). - Update cross-references if you rename or relocate files that are linked in the docs.
Database and migrations
- For schema changes, update both the SQL migration under the relevant
sql/directory and any Go structs/DTOs that map to the same tables. - Provide idempotent migration steps where possible and document required manual steps in the accompanying README or commit message.
Testing summary
Before shipping changes, run the narrowest applicable subset of these commands:
go test ./...(Go services)yarn --cwd dashboard lintyarn --cwd dashboard testyarn --cwd dashboard test:e2e(when you modify Playwright specs or end-to-end flows)
Feedback