|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file is the operational guide for coding agents working in the |
| 4 | +CommandKit monorepo. |
| 5 | + |
| 6 | +## Repository layout |
| 7 | + |
| 8 | +- Monorepo managed with `pnpm` workspaces + Turborepo. |
| 9 | +- Workspace roots: |
| 10 | + - `packages/*` - published/core packages |
| 11 | + - `apps/*` - first-party apps (docs site, test bot, etc.) |
| 12 | +- Key project used as real-world reference: |
| 13 | + - `apps/test-bot` - practical CommandKit usage patterns (plugins, |
| 14 | + JSX components, tasks, workflow, ratelimit, i18n, sharding manager |
| 15 | + pattern) |
| 16 | + |
| 17 | +## First source of truth for agents |
| 18 | + |
| 19 | +Use the skills in `skills/` first, then confirm with code and docs. |
| 20 | + |
| 21 | +- Skills index: `skills/README.md` |
| 22 | +- Core framework skill: `skills/commandkit/SKILL.md` |
| 23 | +- Plugin development skill: |
| 24 | + `skills/commandkit-plugin-development/SKILL.md` |
| 25 | + |
| 26 | +Each skill includes: |
| 27 | + |
| 28 | +- `SKILL.md` with activation guidance and reference/tool tables |
| 29 | +- `references/*.md` with implementation details and best practices |
| 30 | +- optional `tools/*.mjs` helper generators/validators |
| 31 | + |
| 32 | +## CommandKit conventions to preserve |
| 33 | + |
| 34 | +When editing CommandKit projects (especially `apps/test-bot`), |
| 35 | +preserve convention-based discovery: |
| 36 | + |
| 37 | +- Config file at root: `commandkit.config.ts` (or `.js`) |
| 38 | +- App entrypoint: `src/app.ts` (exports discord.js client) |
| 39 | +- Commands: `src/app/commands/**` |
| 40 | +- Events: `src/app/events/**` |
| 41 | +- Optional feature paths: |
| 42 | + - i18n: `src/app/locales/**` |
| 43 | + - tasks: `src/app/tasks/**` |
| 44 | + - workflow: `src/workflows/**` |
| 45 | + - ratelimit runtime config: `ratelimit.ts` |
| 46 | + - sharding manager: `src/sharding-manager.ts` |
| 47 | + |
| 48 | +Important middleware naming conventions: |
| 49 | + |
| 50 | +- `+global-middleware.ts` |
| 51 | +- `+middleware.ts` |
| 52 | +- `+<command>.middleware.ts` |
| 53 | + |
| 54 | +## Preferred implementation workflow |
| 55 | + |
| 56 | +1. Identify the target package/app and relevant skill in `skills/`. |
| 57 | +2. Read the corresponding `references/*.md` for exact patterns. |
| 58 | +3. Mirror existing local conventions (from nearby files) before |
| 59 | + introducing new structures. |
| 60 | +4. Make minimal, focused changes. |
| 61 | +5. Validate with the appropriate command(s). |
| 62 | + |
| 63 | +## Validation commands |
| 64 | + |
| 65 | +From repo root: |
| 66 | + |
| 67 | +- Install deps: `pnpm install` |
| 68 | +- Build packages: `pnpm build` |
| 69 | +- Type-check packages: `pnpm check-types` |
| 70 | +- Format codebase: `pnpm format` |
| 71 | +- Check formatting only: `pnpm prettier:check` |
| 72 | + |
| 73 | +For app-level verification (example test bot): |
| 74 | + |
| 75 | +- `pnpm --filter test-bot dev` |
| 76 | +- `pnpm --filter test-bot build` |
| 77 | +- `pnpm --filter test-bot start` |
| 78 | + |
| 79 | +## Documentation and guide alignment |
| 80 | + |
| 81 | +When adding or changing behavior, keep docs alignment in mind: |
| 82 | + |
| 83 | +- Guide docs: `apps/website/docs/guide/**` |
| 84 | +- API reference docs: `apps/website/docs/api-reference/**` |
| 85 | + |
| 86 | +If you add new user-facing behavior in packages, update the relevant |
| 87 | +guide and/or API reference pages. |
| 88 | + |
| 89 | +## Plugin development guidance |
| 90 | + |
| 91 | +For creating CommandKit plugins: |
| 92 | + |
| 93 | +- Runtime plugin patterns: |
| 94 | + `skills/commandkit-plugin-development/references/01-runtime-plugin-basics.md` |
| 95 | +- Runtime hook mapping: |
| 96 | + `skills/commandkit-plugin-development/references/02-runtime-hooks-reference.md` |
| 97 | +- Compiler transforms: |
| 98 | + `skills/commandkit-plugin-development/references/03-compiler-plugin-transform.md` |
| 99 | +- Template extension hooks: |
| 100 | + `skills/commandkit-plugin-development/references/04-template-registration.md` |
| 101 | +- Rolldown integration: |
| 102 | + `skills/commandkit-plugin-development/references/05-rolldown-plugins.md` |
| 103 | + |
| 104 | +## Safety and quality rules |
| 105 | + |
| 106 | +- Do not introduce APIs that are not already present in the |
| 107 | + codebase/docs unless explicitly asked. |
| 108 | +- Do not break convention-based file discovery paths. |
| 109 | +- Keep changes backward-compatible unless the task explicitly requires |
| 110 | + a breaking change. |
| 111 | +- Prefer explicit error handling in runtime hooks and long-running |
| 112 | + workflows. |
| 113 | +- For interactive JSX components, use valid interaction patterns |
| 114 | + (`onClick` for interactive buttons, link buttons with `url` + |
| 115 | + `ButtonStyle.Link`). |
| 116 | + |
| 117 | +## Git hygiene |
| 118 | + |
| 119 | +- Do not revert unrelated user changes. |
| 120 | +- Keep commits scoped and descriptive when asked to commit. |
| 121 | +- Avoid destructive git operations unless explicitly requested. |
0 commit comments