# Source File Layout

Decides where a file lives, how it is named and where its tests go.

- Repository: https://github.com/lobehub/lobehub (83676 stars)
- Category: Engineering
- License: see repository
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add lobehub/lobehub --skill source-layout -g -a claude-code -y`
Codex: `npx skills add lobehub/lobehub --skill source-layout -g -a codex -y`
Cursor: `npx skills add lobehub/lobehub --skill source-layout -g -a cursor -y`
Gemini CLI: `npx skills add lobehub/lobehub --skill source-layout -g -a gemini-cli -y`

## Description

Use for where a file lives, how it is named, where its tests go, and how to split a source or test file over 1200 lines (拆分大文件, 目录结构, 文件命名).

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Source Layout

Top-level ownership (`src/features`, `src/routes`, `apps/server/src`, `packages`, …) is in `AGENTS.md` and `project-overview`. This skill owns placement and naming inside those roots, test placement, and how a large file becomes a directory. The rules record the conventions the codebase already follows; where it was split between two forms, the rule names the one to use for new files. Do not rename existing files only to match.

## 1. Names

| What                                                 | Form                  | Example                                         |
| ---------------------------------------------------- | --------------------- | ----------------------------------------------- |
| React component file / component directory           | PascalCase            | `PlanCard.tsx`, `ChatInput/ControlBar/`         |
| Hook                                                 | `useXxx.ts(x)`        | `ChatInputNotice/useChatInputNotice.ts`         |
| Other module                                         | camelCase or one word | `originLink.ts`, `recentDirs.ts`                |
| Server class module                                  | the class name        | `services/agentRuntime/StaleOperationReaper.ts` |
| Service, router, store, and other non-component dirs | camelCase             | `services/aiAgent/`, `store/chat/slices/`       |
| Package directory                                    | kebab-case            | `packages/agent-runtime/`                       |
| Files inside a package                               | camelCase             | `packages/database/src/models/`                 |

The rest: https://github.com/lobehub/lobehub/blob/HEAD/.agents/skills/source-layout/SKILL.md
