mains
Copilot instructions8 starsChanged 6 months agoMITView on GitHub
Mains is an Electron 41 desktop app (React 19 renderer, SQLite + Drizzle ORM). CommonJS package with ESM Vite configs (.mjs). macOS only (Apple Silicon and Intel). Three Electron processes with strict boundaries: Every backend domain uses this exact structure (see packages/backend/src/modules/account/ as reference): Critical: All layers are plain object literals, never classes. No DI — repos call getDb() inline. All modules: account, appSettings, automations, browser, connections, entities, fileExplorer, git, guards, imageProxy, projects, providers, pulse, runs, skillsMarketplace, space, stats, sync,…
The file
We split this copilot-instructions.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
Every backend domain uses this exact structure (see packages/backend/src/modules/account/ as reference):
- Very specific: line 43
Critical: All layers are plain object literals, never classes.
- Very specific: line 45
All modules: account, appSettings, automations, browser, connections, entities, fileExplorer, git, guards, imageProxy, projects, providers, …
- Very specific: line 55
All IPC responses use the ServiceResponse<T> envelope, constructed via ok(data) → { success: true, data } or fail(msg) → { success: false, …
- Distinctive: line 77
No Prettier — formatting via editor settings + ESLint
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions — Mains
Mains is an Electron 41 desktop app (React 19 renderer, SQLite + Drizzle ORM). CommonJS package with ESM Vite configs (.mjs). macOS only (Apple Silicon and Intel).
Build & Test
npm start # Dev server (full restart needed for preload changes)
npm run lint # ESLint on src/
npm run lint:fix # Auto-fix
npm run db:generate # Generate Drizzle migrations from schema changes
npm run db:push # Push schema to dev DB (.data/mains.db)
npm run db:studio # Open Drizzle Studio (dev database)
npm run db:studio:runtime # Open Drizzle Studio (runtime database)
npm run db:clean:dev # Reset dev database
npm run db:clean:runtime # Reset runtime database
npm run db:clean:all # Reset both databases
npm run package # Package for current platform
npm run make # Create distributableArchitecture
Three Electron processes with strict boundaries:
- Main (
src/main/) — DB, IPC handlers, business logic in domain modules - Preload (
src/preload/index.ts) — typedwindow.apibridge, namespace-per-domain - Renderer (
src/renderer/) — React + Redux Toolkit + HashRouter,@/alias →src/renderer/
Module Pattern (packages/backend/src/modules/{name}/)
Every backend domain uses this exact structure (see packages/backend/src/modules/account/ as reference):
| File | Role |
{name}.ipc.ts | registerXxxIpc() / unregisterXxxIpc() using ipcMain.handle — calls the service directly (no controller layer) |
{name}.service.ts | Object literal with business logic, uses this for sibling calls; returns Promise<ServiceResponse<T>> |
{name}.repo.ts | Object literal, calls getDb() per method, Drizzle queries |
{name}.dto.ts | Types via typeof table.$inferSelect, formatter functions |
{name}.validation.ts | Hand-rolled allowlist validation (no zod/yup) |
index.ts | Barrel exports |
Critical: All layers are plain object literals, never classes. No DI — repos call getDb() inline.
All modules: account, appSettings, automations, browser, connections, entities, fileExplorer, git, guards, imageProxy, projects, providers, pulse, runs, skillsMarketplace, space, stats, sync, terminal, tools, updates, workspace
IPC Convention
Channel format: "domain:action" (e.g. "runs:start", "entities:getAll"). All channels are defined once in src/shared/ipc-kit/channels.ts as a typed map (CHANNELS.entities.getAll) — never type the channel string literally. Referenced from three sites:
src/preload/index.ts—ipcRenderer.invoke(CHANNELS.entities.getAll, ...)packages/backend/src/modules/{name}/{name}.ipc.ts—ipcMain.handle(CHANNELS.entities.getAll, ...)src/renderer/lib/redux/api/{name}Api.ts—{ handler: CHANNELS.entities.getAll }
All IPC responses use the ServiceResponse<T> envelope, constructed via ok(data) → { success: true, data } or fail(msg) → { success: false, error } (from src/shared/ipc-kit/service-response).
Database (packages/backend/src/db/schema.ts)
- Text primary keys (UUIDs or string literals), timestamps as
integer("col", { mode: "timestamp" })withdefault(sql\(unixepoch())`)` - Snake_case SQL columns, camelCase TypeScript — Drizzle handles mapping
- Booleans:
integer("col", { mode: "boolean" }), enums:text("col", { enum: [...] }) - Updates must manually set
updatedAt: sql\(unixepoch())`` - Index naming:
idx_{table}_{col}, unique:uniq_{table}_{desc}
Frontend Conventions
- Redux: RTK Query with custom
ipcBaseQuery(no HTTP),baseApi.injectEndpoints()per domain - Hooks:
use-kebab-case.tsfilenames,useCamelCaseexport names - Components:
kebab-case.tsxfilenames in feature dirs undersrc/renderer/features/{name}/components/ - Routing: HashRouter — routes at
/,/settings,/copilot[/:workspaceId],/claude[/:workspaceId],/codex[/:workspaceId],/cursor[/:workspaceId],/plugins,/pulse,/relay - Styling: Tailwind CSS v4 (PostCSS-based)
Code Style
- Strict TypeScript, but
anyis allowed (no-explicit-any: off) - Unused vars prefixed with
_(warn, not error) - No Prettier — formatting via editor settings + ESLint
- No
import Reactneeded (react-jsxtransform)
Gotchas
- Preload changes require full dev server restart
- Dual DB paths:
.data/mains.db(dev) vs~/Library/Application Support/mains/mains.db(packaged) - Migration
.sqlfiles are copied into the build via Vite plugin and bundled asextraResource
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

