codebelt-code-style
Original:🇺🇸 English
Translated
Enforces the CodeBelt TypeScript and React code style guide for project structure, naming conventions, component patterns, service patterns, testing, and TypeScript rules. Use when writing, reviewing, or refactoring TypeScript or React code, creating new files or components, organizing project directories, writing tests, defining Zod schemas, or when the user mentions code style, conventions, linting, file organization, or naming patterns.
4installs
Sourcecodebelt/codebelt-skills
Added on
NPX Install
npx skill4agent add codebelt/codebelt-skills codebelt-code-styleTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →CodeBelt Code Style Guide
Opinionated TypeScript and React code style for consistency, maintainability, and scalability. Apply these rules when writing new code, reviewing existing code, or refactoring.
Quick Reference
File Placement
| Code Type | Location |
|---|---|
| React component | |
| API logic | |
| Reusable function | |
| React hook | |
| Third-party config | |
File Extensions
| Extension | Purpose |
|---|---|
| Main code ( |
| Tests |
| TypeScript types |
| Helper functions |
| Tests for utility functions |
| Zod validation schemas |
| Tests for schemas |
| Static objects and constants |
Naming Conventions
| Context | Convention | Example |
|---|---|---|
| Component folders | camelCase | |
| Component files | PascalCase | |
| Everything else | camelCase | |
| Variables/params | Descriptive (no single chars) | |
| Constants | camelCase | |
Exports
All files use named exports only:
typescript
export function Component() {}No default exports. No barrel files in application code.
Workflows
Creating a New Component
- Create folder:
components/{pages|shared|ui}/{componentName}/ - Create component file: with Props type and JSX only
{ComponentName}.tsx - Extract types to (if needed beyond Props)
{ComponentName}.types.ts - Extract constants to (if any)
{ComponentName}.constants.ts - Extract helpers to (if any)
{ComponentName}.utils.ts - Verify: one component per file, Props not exported, named export
Creating a New Service
- Create folder:
services/{provider}/{serviceName}/ - Create main file: with fetch functions and query hooks
{serviceName}.ts - Create schema file: with Zod schemas
{serviceName}.schemas.ts - Create constants file: with query keys
{serviceName}.constants.ts - Verify: schema and type share same name, comment with HTTP method and path
Creating a New Hook
- Create folder:
hooks/use{HookName}/ - Create hook file:
use{HookName}.ts - Create test file:
use{HookName}.test.ts
Creating a New Utility
- Create folder:
utils/{utilName}/ - Create utility file: (no
{utilName}.tssuffix inside.utils.ts)utils/ - Create test file:
{utilName}.test.ts
Detailed References
- Component patterns and hierarchy: See COMPONENTS.md
- Service and schema patterns: See SERVICES.md
- Testing patterns: See TESTING.md
- Common mistakes to avoid: See MISTAKES.md