AGENT SKILL

architecture

Project architecture and file structure conventions for all process types. Use when: (1) Creating new files or modules, (2) Deciding where code should go, (3) Converting single-file components to directories, (4) Reviewing code for structure compliance, (5) Adding new bridges, services, agents, or workers.

License 许可
Apache-2.0
最近更新
2026-06-23
Stars
★ 1
Forks
0

01 前言 Front Matter

name
architecture
description
Project architecture and file structure conventions for all process types. Use when: (1) Creating new files or modules, (2) Deciding where code should go, (3) Converting single-file components to directories, (4) Reviewing code for structure compliance, (5) Adding new bridges, services, agents, or workers.

02 资源文件 3

03 SKILL.md 正文

Architecture Skill

Determine correct file placement and structure for an Electron multi-process project.

Detailed References


Decision Tree — Where Does New Code Go?

Is it UI (React components, hooks, pages)?
  └── YES → packages/desktop/src/renderer/              → see references/renderer.md

Is it an IPC handler responding to renderer calls?
  └── YES → packages/desktop/src/process/bridge/        → see references/process.md

Is it business logic running in the main process?
  └── YES → packages/desktop/src/process/services/      → see references/process.md

Is it an AI platform connection (API client, message protocol)?
  └── YES → packages/desktop/src/process/agent/<platform>/

Is it a background task that runs in a worker thread?
  └── YES → packages/desktop/src/process/worker/

Is it used by BOTH main and renderer processes?
  └── YES → packages/desktop/src/common/

Is it an HTTP/WebSocket endpoint?
  └── YES → packages/desktop/src/process/webserver/

Is it a plugin/extension resolver or loader?
  └── YES → packages/desktop/src/process/extensions/

Is it a messaging channel (Lark, DingTalk, Telegram)?
  └── YES → packages/desktop/src/process/channels/

Process Boundary Rules

Hard rules — violating them causes runtime crashes.

Process Can use Cannot use
Main (packages/desktop/src/process/) Node.js, Electron main APIs, fs, path, child_process DOM APIs (document, window, React)
Renderer (packages/desktop/src/renderer/) DOM APIs, React, browser APIs Node.js APIs (fs, path), Electron main APIs
Worker (packages/desktop/src/process/worker/) Node.js APIs DOM APIs, Electron APIs
Preload (packages/desktop/src/preload/) contextBridge, ipcRenderer DOM manipulation, Node.js fs

Cross-process communication:

  • Main ↔ Renderer: IPC via packages/desktop/src/preload/ + packages/desktop/src/process/bridge/*.ts
  • Main ↔ Worker: fork protocol via packages/desktop/src/process/worker/WorkerProtocol.ts
// NEVER in renderer
import { something } from '@process/services/foo'; // crashes at runtime

// Use IPC instead
const result = await window.api.someMethod(); // goes through preload

Naming Conventions

Directories

Scope Convention Reason
Renderer component/module dirs PascalCase React convention — dir name = component name
Everything else lowercase Node.js convention
Categorical dirs (everywhere) lowercase components/, hooks/, utils/, services/
Platform dirs (everywhere) lowercase acp/, codex/, gemini/ — cross-process consistency

Quick test: "Inside packages/desktop/src/renderer/ AND represents a specific component/feature (not a category)?" → PascalCase. Otherwise → lowercase.

Files

Content Convention Examples
React components, classes PascalCase SettingsModal.tsx, CronService.ts
Hooks camelCase with use prefix useTheme.ts, useCronJobs.ts
Utilities, helpers camelCase formatDate.ts, cronUtils.ts
Entry points index.ts / index.tsx Required for directory-based modules
Config, types, constants camelCase types.ts, constants.ts
Styles kebab-case or Name.module.css chat-layout.css

Structural Rules

  1. Directory size limit: Max 10 direct children. Split into subdirectories by responsibility when approaching.
  2. No single-file directories: Merge into parent or related directory.
  3. Single file vs directory: If a component needs a private sub-component or hook, convert to a directory with index.tsx.
  4. Page-private first: Start code in pages/<PageName>/. Promote to shared only when a second consumer appears.

Test File Mapping

Tests mirror source files in tests/ subdirectories:

Source Test
packages/desktop/src/process/services/CronService.ts tests/unit/cronService.test.ts
packages/desktop/src/renderer/hooks/ui/useAutoScroll.ts tests/unit/useAutoScroll.dom.test.ts
packages/desktop/src/process/extensions/ExtensionLoader.ts tests/unit/extensions/extensionLoader.test.ts

When tests/unit/ exceeds 10 direct children, group into subdirectories matching source structure.


Quick Checklist

  • [ ] Code is in the correct process directory (no cross-process imports)
  • [ ] Renderer code does not use Node.js APIs
  • [ ] Main process code does not use DOM APIs
  • [ ] New IPC channels are bridged through preload.ts
  • [ ] Renderer component/module dirs use PascalCase; categorical dirs use lowercase
  • [ ] Platform dirs use lowercase everywhere
  • [ ] Directory-based modules have index.tsx / index.ts entry point
  • [ ] Page-private code is under pages/<PageName>/, not in shared dirs
  • [ ] No single-file directories
  • [ ] No directory exceeds 10 direct children
  • [ ] New source files are auto-included in coverage — verify they are not accidentally excluded in vitest.config.ts → coverage.exclude
  • [ ] New services separate pure logic from IO

04 同仓库更多 Skills

oliverhees
oliverhees/LokkyWork

testing

Testing workflow and quality standards for writing and running tests. Use when: (1) Writing new tests, (2) Adding a new feature that needs tests, (3) Modifying logic that has existing tests, (4) Before claiming a task is complete.

★ 1
oliverhees
oliverhees/LokkyWork

pr-verify

PR Verification & Merge: verify bot:ready-to-merge PRs with impact analysis, test supplementation, and one-click merge. Use when: (1) User says "/pr-verify", (2) User wants to verify and merge ready PRs.

★ 1
oliverhees
oliverhees/LokkyWork

pr-ship

End-to-end PR lifecycle: create PR, wait for CI, review, fix issues, merge — all in one invocation. Use when: (1) User says "/pr-ship", (2) User wants to ship current changes as a complete PR lifecycle, (3) User wants to resume shepherding an existing PR.

★ 1
oliverhees
oliverhees/LokkyWork

pr-review

PR Code Review (Local): perform a thorough local code review with full project context. Use when: (1) User asks to review a PR, (2) User says "/pr-review", (3) User wants to review code changes before merging.

★ 1
oliverhees
oliverhees/LokkyWork

pr-fix

PR Review Fix: automatically fix all issues identified in a pr-review report. Use when: (1) User says "fix all review issues", (2) User says "/pr-fix", (3) After pr-review skill has produced a report, (4) User wants to address PR review feedback.

★ 1
oliverhees
oliverhees/LokkyWork

pr-automation

PR Automation Orchestrator: poll open PRs, check CI, run review, fix, and merge eligible PRs. Use when: (1) Invoked by daemon via scripts/pr-automation.sh, (2) User says "/pr-automation".

★ 1