Copilot instructions
.github/copilot-instructions.mdCopilot instructions
Quality
86/100
Scores the file, not the repository.Length
602 words
17 headings · 5 code blocksRepository
122k
— · pushed 0 days agoLast changed
3 days ago
First indexed 3 days ago.1# Copilot Instructions for Electron23## Build System45Electron uses `@electron/build-tools` (`e` CLI). Install with `npm i -g @electron/build-tools`.67```bash8e sync # Fetch sources and apply patches9e build # Build Electron (GN + Ninja)10e build -k 999 # Build, continuing through errors11e start # Run built Electron12e start --version # Verify Electron launches13e test # Run full test suite14e debug # Run in debugger (lldb on macOS, gdb on Linux)15```1617### Linting1819```bash20npm run lint # Run all linters (JS, C++, Python, GN, docs)21npm run lint:js # JavaScript/TypeScript only22npm run lint:clang-format # C++ formatting only23npm run lint:cpp # C++ linting only24npm run lint:docs # Documentation only25```2627### Running a Single Test2829```bash30npm run test -- -g "pattern" # Run tests matching a regex pattern31# Example: npm run test -- -g "ipc"32```3334### Running a Single Node.js Test3536```bash37node script/node-spec-runner.js parallel/test-crypto-keygen38```3940## Architecture4142Electron embeds Chromium (rendering) and Node.js (backend) to enable desktop apps with web technologies. The parent directory (`../`) is the Chromium source tree.4344### Process Model4546Electron has two primary process types, mirroring Chromium:4748- **Main process** (`shell/browser/` + `lib/browser/`): Controls app lifecycle, creates windows, system APIs49- **Renderer process** (`shell/renderer/` + `lib/renderer/`): Runs web content in BrowserWindows5051### Native ↔ JavaScript Bridge5253Each API is implemented as a C++/JS pair:5455- C++ side: `shell/browser/api/electron_api_{name}.cc/.h` — uses `gin::Wrappable` and `ObjectTemplateBuilder`56- JS side: `lib/browser/api/{name}.ts` — exports the module, registered in `lib/browser/api/module-list.ts`57- Binding: `NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_{name}, Initialize)` in C++ and registered in `shell/common/node_bindings.cc`58- Type declaration: `typings/internal-ambient.d.ts` maps `process._linkedBinding('electron_browser_{name}')`5960### Patches System6162Electron patches upstream dependencies (Chromium, Node.js, V8, etc.) rather than forking them. Patches live in `patches/` organized by target, with `patches/config.json` mapping directories to repos.6364```text65patches/{target}/*.patch → [e sync] → target repo commits66 ← [e patches] ←67```6869Key rules:7071- Fix existing patches rather than creating new ones72- Preserve original authorship in TODO comments — never change `TODO(name)` assignees73- Each patch commit message must explain why the patch exists74- After modifying patches, run `e patches {target}` to export7576When working on the `roller/chromium/main` branch for Chromium upgrades, use `e sync --3` for 3-way merge conflict resolution.7778## Conventions7980### File Naming8182- JS/TS files: kebab-case (`file-name.ts`)83- C++ files: snake_case with `electron_api_` prefix (`electron_api_safe_storage.cc`)84- Test files: `api-{module-name}-spec.ts` in `spec/`85- Source file lists are maintained in `filenames.gni` (with platform-specific sections)8687### JavaScript/TypeScript8889- Semicolons required (`"semi": ["error", "always"]`)90- `const` and `let` only (no `var`)91- Arrow functions preferred92- Import order enforced: `@electron/internal` → `@electron` → `electron` → external → builtin → relative93- API naming: `PascalCase` for classes (`BrowserWindow`), `camelCase` for module APIs (`globalShortcut`)94- Prefer getters/setters over jQuery-style `.text([text])` patterns9596### C++9798- Follows Chromium coding style, enforced by `clang-format` and `clang-tidy`99- Uses Chromium abstractions (`base::`, `content::`, etc.)100- Header guards: `#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_{NAME}_H_`101- Platform-specific files: `_mac.mm`, `_win.cc`, `_linux.cc`102103### Testing104105- Framework: Mocha + Chai + Sinon106- Test helpers in `spec/lib/` (e.g., `spec-helpers.ts`, `window-helpers.ts`)107- Use `defer()` from spec-helpers for cleanup, `closeAllWindows()` for window teardown108- Tests import from `electron/main` or `electron/renderer`109110### Documentation111112- API docs in `docs/api/` as Markdown, parsed by `@electron/docs-parser` to generate `electron.d.ts`113- API history tracked via YAML blocks in HTML comments within doc files114- Docs must pass `npm run lint:docs`115116### Build Configuration117118- `BUILD.gn`: Main GN build config119- `buildflags/buildflags.gni`: Feature flags (PDF viewer, extensions, spellchecker)120- `build/args/`: Build argument profiles (`testing.gn`, `release.gn`, `all.gn`)121- `DEPS`: Dependency versions and checkout paths122- `chromium_src/`: Chromium source file overrides (compiled instead of originals)123
Also in electron/electron
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| electron/electronCLAUDE.md · 122k | CLAUDE.md | setupbuildteststyle+5 | 96/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| chihebnabil/lovable-boilerplate.github/instructions/global.instructions.md · 63 | Copilot instructions | buildlint-formatstylearch+4 | 100/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 3 days ago | |
| louislam/uptime-kuma.github/copilot-instructions.md · 90k | Copilot instructions | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.github/copilot-instructions.md · 31k | Copilot instructions | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| bagisto/bagisto.github/copilot-instructions.md · 28k | Copilot instructions | setupbuildteststyle+5 | 97/100 | 3 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 24 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| nerolis-lab/nerolis-lab.github/copilot-instructions.md · 32 | Copilot instructions | setupbuildtestlint-format+11 | 96/100 | 3 days ago | |
| thangaram611/second-brain.github/copilot-instructions.md · 0 | Copilot instructions | setupteststylearch+4 | 96/100 | 3 days ago |
