|
| 1 | +# Arkstack Agent Skills |
| 2 | + |
| 3 | +This file describes discrete capabilities an AI agent can call when working inside an Arkstack project. It is intended to be provided as project context to tools such as Claude, Codex, Cursor, and other coding agents. |
| 4 | + |
| 5 | +Agents should prefer the project's package manager scripts and the `ark` CLI over hand-written file scaffolding when a first-party command exists. |
| 6 | + |
| 7 | +## Environment Discovery |
| 8 | + |
| 9 | +- Identify the package manager from lockfiles: prefer `pnpm` when `pnpm-lock.yaml` is present. |
| 10 | +- Inspect `package.json` scripts before running commands. |
| 11 | +- Detect the runtime driver from dependencies: `@arkstack/driver-h3` for H3, `@arkstack/driver-express` for Express. |
| 12 | +- Detect full vs lean templates by checking for database files, Arkormx dependencies, and `src/app` structure. |
| 13 | +- Read `.env`, `.env.example`, `arkormx.config.ts`, `tsdown.config.ts`, and route files only as needed for the task. |
| 14 | + |
| 15 | +## Project Commands |
| 16 | + |
| 17 | +Use these commands from the Arkstack project root when available: |
| 18 | + |
| 19 | +- `pnpm dev` or `pnpm ark dev`: run the development server through `tsdown` in development mode. |
| 20 | +- `pnpm build` or `pnpm ark build`: build the application for production. |
| 21 | +- `pnpm test`: run the Vitest test suite. |
| 22 | +- `pnpm test:watch`: run Vitest in watch mode. |
| 23 | +- `pnpm lint`: run ESLint checks. |
| 24 | +- `pnpm lint:fix`: apply ESLint fixes. |
| 25 | +- `pnpm ark --help`: list available console commands. |
| 26 | +- `pnpm ark <command> --help`: inspect command options before generating or mutating files. |
| 27 | + |
| 28 | +In this monorepo, additional root commands exist: |
| 29 | + |
| 30 | +- `pnpm build:packages`: build all `@arkstack/*` packages. |
| 31 | +- `pnpm test:coverage`: run tests with coverage. |
| 32 | +- `pnpm docs:dev`: run VitePress documentation locally. |
| 33 | +- `pnpm docs:build`: build the documentation site. |
| 34 | +- `pnpm docs:preview`: preview the built documentation. |
| 35 | + |
| 36 | +## Route Inspection |
| 37 | + |
| 38 | +Use `pnpm ark route:list` to list registered routes. |
| 39 | + |
| 40 | +Useful options: |
| 41 | + |
| 42 | +- `--path <value>` or `-p <value>`: filter by route path. |
| 43 | +- `--method <value>` or `-m <value>`: filter by HTTP method. |
| 44 | + |
| 45 | +Use this before changing controllers, middleware, or route definitions so the agent can verify the effective route table. |
| 46 | + |
| 47 | +## Controller Generation |
| 48 | + |
| 49 | +Use `pnpm ark make:controller <Name>` to create a controller in `src/app/http/controllers`. |
| 50 | + |
| 51 | +Useful options: |
| 52 | + |
| 53 | +- `--api`: generate an API-style controller. |
| 54 | +- `--model <Name>` or `-m <Name>`: attach model context and create the model if needed. |
| 55 | +- `--factory` or `-f`: create a linked factory when using `--model`. |
| 56 | +- `--seeder` or `-s`: create a linked seeder when using `--model`. |
| 57 | +- `--migration` or `-x`: create a linked migration when using `--model`. |
| 58 | +- `--force`: overwrite an existing generated controller. |
| 59 | + |
| 60 | +Prefer this command over manually copying controller stubs. Generated controllers use driver-specific stubs from `node_modules/@arkstack/driver-<driver>/stubs` or the local `stubs` directory. |
| 61 | + |
| 62 | +## Resource Generation |
| 63 | + |
| 64 | +Use `pnpm ark make:resource <type> <Name>` to generate response resources through Resora. |
| 65 | + |
| 66 | +Common forms: |
| 67 | + |
| 68 | +- `pnpm ark make:resource resource User` |
| 69 | +- `pnpm ark make:resource collection UserCollection` |
| 70 | +- `pnpm ark make:resource all User` |
| 71 | + |
| 72 | +Use `pnpm ark make:full-resource <Prefix>` to create a resource, collection, and API controller together. |
| 73 | + |
| 74 | +Useful options for `make:full-resource`: |
| 75 | + |
| 76 | +- `--model <Name>` or `-m <Name>`: attach model context. |
| 77 | +- `--factory` or `-f`: create a linked factory. |
| 78 | +- `--seeder` or `-s`: create a linked seeder. |
| 79 | +- `--migration` or `-x`: create a linked migration. |
| 80 | +- `--force`: overwrite generated resource/controller files. |
| 81 | + |
| 82 | +## Database and Modeling |
| 83 | + |
| 84 | +Full Arkstack templates use Arkormx through the Arkstack CLI. |
| 85 | + |
| 86 | +Available database skills: |
| 87 | + |
| 88 | +- `pnpm ark make:model <Name>`: create a model. |
| 89 | +- `pnpm ark make:migration <name>`: create a migration. |
| 90 | +- `pnpm ark make:factory <Name>`: create a model factory. |
| 91 | +- `pnpm ark make:seeder <Name>`: create a seeder. |
| 92 | +- `pnpm ark migrate`: run pending migrations. |
| 93 | +- `pnpm ark migrate:fresh`: rebuild the database from scratch. Ask for explicit user approval before running because it is destructive. |
| 94 | +- `pnpm ark migrate:rollback`: roll back migrations. Ask for approval before running against non-local data. |
| 95 | +- `pnpm ark migrate:history`: inspect migration history. |
| 96 | +- `pnpm ark models:sync`: sync model files with the database schema. |
| 97 | +- `pnpm ark seed`: run seeders. |
| 98 | + |
| 99 | +Conventions: |
| 100 | + |
| 101 | +- Models belong in `src/app/models` in scaffolded apps. |
| 102 | +- Migrations belong in `src/database/migrations`. |
| 103 | +- Factories belong in `src/database/factories`. |
| 104 | +- Seeders belong in `src/database/seeders`. |
| 105 | +- Use `arkormx.config.ts` for database build output and schema configuration. |
| 106 | + |
| 107 | +## View Generation |
| 108 | + |
| 109 | +Use `pnpm ark make:view <name>` to create an Edge view in `src/resources/views`. |
| 110 | + |
| 111 | +Conventions: |
| 112 | + |
| 113 | +- Dots and slashes become nested view paths. |
| 114 | +- `.edge` is appended automatically. |
| 115 | +- Use `--force` only when intentionally replacing an existing view. |
| 116 | + |
| 117 | +## Storage Links |
| 118 | + |
| 119 | +Use `pnpm ark storage:link` when the filesystem package is installed and the app defines `filesystem.links`. |
| 120 | + |
| 121 | +Useful option: |
| 122 | + |
| 123 | +- `--force`: remove existing links before creating new ones. Ask for confirmation before using this on an existing project. |
| 124 | + |
| 125 | +## Custom Console Commands |
| 126 | + |
| 127 | +Use `pnpm ark make:command <Name>` to create a command class in `src/app/console/commands`. |
| 128 | + |
| 129 | +Conventions: |
| 130 | + |
| 131 | +- Generated command class names end with `Command`. |
| 132 | +- Generated command signatures default to `app:<lowercase-command-name>`. |
| 133 | +- Custom commands are auto-discovered by the console kernel. |
| 134 | + |
| 135 | +## File Editing Skills |
| 136 | + |
| 137 | +Agents can safely edit these common Arkstack areas when the task calls for it: |
| 138 | + |
| 139 | +- `src/routes`: route registration. |
| 140 | +- `src/app/http/controllers`: HTTP controllers. |
| 141 | +- `src/app/http/middlewares`: middleware. |
| 142 | +- `src/app/http/resources`: resource and collection response shaping. |
| 143 | +- `src/app/models`: application models. |
| 144 | +- `src/app/services`: business logic. |
| 145 | +- `src/app/console/commands`: custom commands. |
| 146 | +- `src/database/migrations`: database migrations. |
| 147 | +- `src/database/factories`: test or seed factories. |
| 148 | +- `src/database/seeders`: seed data. |
| 149 | +- `src/resources/views`: Edge templates. |
| 150 | +- `src/config` or `config`: configuration files. |
| 151 | +- `tests`: Vitest tests. |
| 152 | +- `docs`: VitePress documentation. |
| 153 | + |
| 154 | +Rules: |
| 155 | + |
| 156 | +- Prefer generated files for new Arkstack primitives, then edit the generated result. |
| 157 | +- Keep runtime-specific code inside driver, middleware, or bootstrap boundaries. |
| 158 | +- Keep business logic in services or framework-neutral modules when practical. |
| 159 | +- Do not edit generated build output such as `dist`, `.arkstack/build`, or coverage artifacts. |
| 160 | + |
| 161 | +## Testing and Verification |
| 162 | + |
| 163 | +Pick the smallest useful verification for the change: |
| 164 | + |
| 165 | +- Run `pnpm test` after behavior changes. |
| 166 | +- Run targeted Vitest files when the project supports them. |
| 167 | +- Run `pnpm lint` after broad TypeScript or formatting changes. |
| 168 | +- Run `pnpm build` after package exports, runtime entrypoints, CLI commands, or build config changes. |
| 169 | +- Run `pnpm docs:build` after VitePress docs or sidebar changes. |
| 170 | +- Run `pnpm ark route:list` after route/controller/middleware changes. |
| 171 | + |
| 172 | +## Safety Rules |
| 173 | + |
| 174 | +- Ask before running destructive database commands such as `migrate:fresh`, broad rollback commands, or forced storage links. |
| 175 | +- Ask before deleting user files or replacing existing generated files with `--force`. |
| 176 | +- Do not commit, publish, or release unless explicitly requested. |
| 177 | +- Do not assume a database is disposable unless the user says it is local/test data. |
| 178 | +- Preserve project conventions and inspect nearby files before introducing a new pattern. |
0 commit comments