一键导入
coding-standards
Project coding standards and conventions. Loaded automatically when writing or reviewing code to ensure consistency.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Project coding standards and conventions. Loaded automatically when writing or reviewing code to ensure consistency.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guides building and testing conversational Claude skills. Use when creating a new skill, reviewing an existing skill, or iterating on skill design. Trigger when users say things like "create a new skill", "build a skill", "review this skill", or "make this skill better."
Deeply analyze codebase architecture and dependencies. Use when understanding system design, finding patterns, or mapping how components interact.
Fix a GitHub issue by implementing the requested changes
Summarize changes and discussion in a pull request
Brief description of when to use this skill
| name | coding-standards |
| description | Project coding standards and conventions. Loaded automatically when writing or reviewing code to ensure consistency. |
| user-invocable | false |
These standards apply automatically when working with code in this project.
// Classes: PascalCase
class UserRepository {}
// Functions/methods: camelCase
function getUserById(id: string) {}
// Constants: UPPER_SNAKE_CASE
const MAX_RETRY_ATTEMPTS = 3;
// Private properties: _prefixed
class Example {
private _internalState: string;
}
// Boolean variables: is/has/should prefix
const isValid = true;
const hasPermission = false;
const shouldRetry = true;
src/
├── components/ # UI components
│ ├── Button/
│ │ ├── Button.tsx
│ │ ├── Button.test.tsx
│ │ └── index.ts # Re-exports
├── hooks/ # React hooks
├── utils/ # Pure utility functions
├── services/ # API and external services
├── types/ # TypeScript type definitions
└── constants/ # App-wide constants
Always order imports:
// External
import React from 'react';
import { format } from 'date-fns';
// Internal
import { Button } from '@/components/Button';
import { useAuth } from '@/hooks/useAuth';
// Relative
import { helper } from './utils';
import styles from './Component.module.css';
// Types
import type { User } from '@/types';
// Good
try {
const result = await riskyOperation();
return result;
} catch (error) {
logger.error('Operation failed:', error);
throw new ApplicationError('Failed to complete operation', { cause: error });
}
// Bad - silent failures
try {
await riskyOperation();
} catch (error) {
// Ignored
}
class ValidationError extends Error {
constructor(message: string, public field: string) {
super(message);
this.name = 'ValidationError';
}
}
test('should calculate total with tax', () => {
// Arrange
const items = [{ price: 100 }, { price: 200 }];
const taxRate = 0.1;
// Act
const total = calculateTotal(items, taxRate);
// Assert
assert.strictEqual(total, 330);
});
Use descriptive names that explain the scenario:
// Good
test('returns 404 when user does not exist')
test('throws ValidationError when email is invalid')
test('caches result after first successful fetch')
// Bad
test('test user')
test('error case')
test('it works')
// Good - clear contract
export function processUser(id: string): Promise<User> {
// ...
}
// Okay - internal functions can infer
function formatDate(date: Date) {
return date.toISOString();
}
// Good
function parseJSON(input: string): unknown {
return JSON.parse(input);
}
// Bad
function parseJSON(input: string): any {
return JSON.parse(input);
}
// Good - type guard
function isUser(obj: unknown): obj is User {
return typeof obj === 'object' && obj !== null && 'id' in obj;
}
// Bad - assertion
const user = data as User;
// Good
// Using debounce to prevent excessive API calls during typing
const debouncedSearch = debounce(search, 300);
// Bad
// Set x to 5
const x = 5;
// Good - self-documenting
function isEligibleForDiscount(user: User): boolean {
return user.isPremium && user.purchaseCount > 10;
}
// Bad - needs comment to explain
function check(u: User): boolean {
// Check if user gets discount
return u.p && u.c > 10;
}
Follow Conventional Commits:
type(scope): subject
body
footer
Types:
feat: New featurefix: Bug fixdocs: Documentation onlyrefactor: Code change that neither fixes nor adds featuretest: Adding or updating testschore: Maintenance (dependencies, config)Examples:
feat(auth): add password reset functionality
Implements email-based password reset flow with token expiration.
Closes #123
fix(api): handle null response from external service
The third-party API occasionally returns null instead of empty array.
Added null check to prevent runtime errors.
feature/short-description
fix/issue-number-description
refactor/component-name
docs/what-is-documented
// Memoize expensive computations
const memoized = useMemo(() => expensiveOperation(data), [data]);
// Debounce user input
const debouncedHandler = debounce(handleInput, 300);
// Lazy load heavy components
const HeavyComponent = lazy(() => import('./HeavyComponent'));
// Good - validate and sanitize
function createUser(input: unknown) {
const validated = userSchema.parse(input);
const sanitized = sanitize(validated);
return db.users.create(sanitized);
}
// Good
const apiKey = process.env.API_KEY;
// Bad - hardcoded secret
const apiKey = 'sk-abc123...';
For more detailed specifications:
This is a background knowledge skill that loads automatically when Claude writes or reviews code. It ensures consistency across the codebase without requiring manual invocation.