skills/file-organization/SKILL.md
File organization, naming conventions, and import patterns (no barrel files, direct imports, kebab-case docs, ESM config). Use when creating new files, modules, refactoring imports, or setting up directory structures.
npx skillsauth add bkinsey808/songshare-effect file-organizationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Requires: file-read, terminal (linting/testing). No network access needed.
Use this skill when:
Execution workflow:
npm run lint after meaningful structure/import changes.Output requirements:
❌ Never create index.ts re-export files:
// BAD: react/src/components/index.ts
export { SongCard } from "./SongCard";
export { UserProfile } from "./UserProfile";
✅ Always import directly from source:
// GOOD
import { SongCard } from "./components/SongCard";
import { UserProfile } from "./components/UserProfile";
This applies everywhere: no export { something } from "./somefile" re-exports.
Linting requirement: After making any code change (including refactors and imports), run npm run lint from the project root and address any failures before finalizing the change or opening a PR. If lint fails, do not merge — fix or escalate.
// ✅ All types — use import type
import type { PopoverProps, PopoverState } from "./popover/types";
// ✅ Mixed imports — type keyword on individual types
import { NativePopover } from "./popover/NativePopover";
import { type PopoverProps } from "./popover/types";
// ❌ Avoid inline type when all imports are types
import { type PopoverProps, type PopoverState } from "./popover/types";
UserProfile.tsx, SongCard.tsxformatDate.ts, calculateDuration.tsauth-utils.ts, api-helpers.ts.test-util.ts / .test-util.tsx suffix (e.g. mockUseSlideManagerView.test-util.ts)song-library/, auth-flow/[SourceName].test.ts or [SourceName].test.tsx.spec.ts under e2e/docs/: authentication-system.md, effect-implementation.md.js with export default, not .cjsvite.config.js, tsconfig.json, tailwind.config.js — preserve original names.bun.ts extension for scripts run under Bun: scripts/postinstall-playwright.bun.tssongshare-effect/
├── api/
│ └── src/
│ ├── api-errors.ts # Shared error types
│ ├── env.ts
│ ├── hono/ # Hono context utilities
│ ├── supabase/ # Supabase client helpers
│ │ ├── getSupabaseClientToken.ts
│ │ └── tokenCache.ts
│ └── <feature>/ # Feature dirs (community, event, auth, …)
├── react/
│ └── src/
│ ├── auth/
│ │ ├── slice/ # Auth state (createAuthSlice.ts)
│ │ └── SignInButtons.tsx
│ ├── lib/ # Shared React utilities
│ │ └── supabase/ # Supabase client + token helpers
│ └── <feature>/ # Feature dirs with colocated tests
├── shared/
│ └── src/
│ ├── generated/ # DB schema + types (auto-generated)
│ └── <domain>/ # Shared types/utils per domain
├── docs/ # kebab-case .md files
└── scripts/
Rules:
index.ts re-export files anywhereUse absolute paths (@/) for test helpers or utilities imported from multiple different locations:
// ✅ GOOD: Same absolute path from any caller
import mockUseSlideManagerView from "@/react/event/manage/test-utils/mockUseSlideManagerView.test-util";
// ❌ BAD: Relative paths break when caller depth changes
import mockUseSlideManagerView from "./test-utils/mockUseSlideManagerView.test-util";
Path aliases: @/api/ = api/src/, @/shared/ = shared/src/, @/react/ = react/src/
// 1. External packages
import React from "react";
import { Effect } from "effect";
// 2. Internal absolute imports
import { AppError } from "@/api/api-errors";
import mockHelper from "@/react/event/manage/test-utils/mockHelper.test-util";
// 3. Internal relative imports
import { SongCard } from "../components/SongCard";
import { type SongLibraryProps } from "./types";
// 4. Type-only imports last
import type { Metadata } from "@/shared/types/metadata";
To fix a file that imports from barrel files:
import { NativePopover } from "./popover";popover/ directoryimport { NativePopover } from "./popover/NativePopover";
import { calculatePosition } from "./popover/calculatePosition";
import { type PopoverProps } from "./popover/types";
# Find all index.ts files (should be absent)
find . -name "index.ts" -not -path "./node_modules/*"
# Check for CommonJS config files (should use .js with ESM)
find . -name "*.cjs" -not -path "./node_modules/*"
# Lint
npm run lint
docs/ai/rules.md.file-splitting.naming-conventions.For maintainability and discoverability, prefer placing constants close to their single consumers.
const near the top of the file (not in a separate constants.ts). This keeps the API surface small and makes the constant easy to refactor.constants.ts or feature-name-constants.ts) and import from it. Name the file descriptively and keep exports grouped.Examples:
// Single-file use (preferred):
// File: react/src/song/SongForm.tsx
const DEFAULT_MIN_CHORD_NOTES = 3;
// Shared use (>=3 callers):
// File: shared/src/music/constants.ts
export const DEFAULT_MIN_CHORD_NOTES = 3;
// Importing from multiple callers
import { DEFAULT_MIN_CHORD_NOTES } from "@/shared/music/constants";
Rationale:
When in doubt, ask the reviewer — prefer a short discussion in the PR rather than guessing placement.
tools
Zustand state management patterns for this project — store creation, selectors, Immer middleware, async actions with loading states, devtools, persist, and testing. Use when authoring or editing Zustand stores (use*Store files) or components that subscribe to stores. Do NOT use for React component structure or TypeScript-only utilities.
testing
How to write, update, or split skill files in this repo. Use when creating a new SKILL.md, updating an existing one, or deciding whether to put content in a skill vs. docs/.
development
Complete guide for testing React hooks — renderHook, Documentation by Harness, installStore, fixtures, subscription patterns, lint/compiler traps, and pre-completion checklist. Read docs/testing/unit-test-hook-best-practices.md for the full reference.
development
Vitest unit test authoring for this repo — setup, mocking, API handler testing, and common pitfalls for non-hook code. Use when the user asks to add, update, fix, or review unit tests for utilities, components, API handlers, or scripts. Do NOT use for React hook tests — load unit-test-hook-best-practices instead.