copilot-docs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGitHub Copilot Custom Instructions
GitHub Copilot 自定义指令
Configure repository-specific instructions for GitHub Copilot.
为GitHub Copilot配置仓库专属的指令。
Quick Start
快速开始
Create in your repository:
.github/copilot-instructions.mdmarkdown
undefined在你的仓库中创建文件:
.github/copilot-instructions.mdmarkdown
undefinedCopilot Instructions
Copilot Instructions
Code Style
Code Style
- Use TypeScript with strict mode
- Prefer functional components with hooks
- Use Tailwind CSS for styling
- Use TypeScript with strict mode
- Prefer functional components with hooks
- Use Tailwind CSS for styling
Project Context
Project Context
This is a Next.js 14 app using the App Router.
API routes are in .
app/api/undefinedThis is a Next.js 14 app using the App Router.
API routes are in .
app/api/undefinedEffective Patterns
实用模式
Project Context
项目上下文
markdown
undefinedmarkdown
undefinedProject Context
Project Context
Tech Stack
Tech Stack
- Next.js 14 with App Router
- TypeScript 5.3+
- Tailwind CSS 3.4
- Prisma ORM with PostgreSQL
- Next.js 14 with App Router
- TypeScript 5.3+
- Tailwind CSS 3.4
- Prisma ORM with PostgreSQL
Architecture
Architecture
- - Next.js App Router pages and API routes
app/ - - React components
components/ - - Utility functions and shared code
lib/ - - Database schema and migrations
prisma/
undefined- - Next.js App Router pages and API routes
app/ - - React components
components/ - - Utility functions and shared code
lib/ - - Database schema and migrations
prisma/
undefinedCode Standards
代码规范
markdown
undefinedmarkdown
undefinedCode Standards
Code Standards
TypeScript
TypeScript
- Enable strict mode
- Prefer over
interfacefor object shapestype - Use explicit return types on functions
- Enable strict mode
- Prefer over
interfacefor object shapestype - Use explicit return types on functions
React
React
- Use functional components exclusively
- Prefer named exports
- Extract hooks to directory
hooks/
- Use functional components exclusively
- Prefer named exports
- Extract hooks to directory
hooks/
Error Handling
Error Handling
- Use Result pattern for fallible operations
- Always handle async errors with try/catch
- Log errors with structured format
undefined- Use Result pattern for fallible operations
- Always handle async errors with try/catch
- Log errors with structured format
undefinedNaming Conventions
命名规范
markdown
undefinedmarkdown
undefinedNaming Conventions
Naming Conventions
Files
Files
- Components: PascalCase (Button.tsx)
- Utilities: camelCase (formatDate.ts)
- Constants: SCREAMING_SNAKE_CASE
- Components: PascalCase (Button.tsx)
- Utilities: camelCase (formatDate.ts)
- Constants: SCREAMING_SNAKE_CASE
Code
Code
- Boolean variables: is*, has*, should* prefix
- Event handlers: handle* prefix (handleClick)
- Async functions: *Async suffix
undefined- Boolean variables: is*, has*, should* prefix
- Event handlers: handle* prefix (handleClick)
- Async functions: *Async suffix
undefinedTesting
测试指南
markdown
undefinedmarkdown
undefinedTesting Guidelines
Testing Guidelines
Unit Tests
Unit Tests
- Use Vitest for unit testing
- Place tests next to source files (*.test.ts)
- Mock external dependencies
- Use Vitest for unit testing
- Place tests next to source files (*.test.ts)
- Mock external dependencies
Test Patterns
Test Patterns
typescript
describe('Component', () => {
it('should render correctly', () => {
// Arrange, Act, Assert pattern
});
});undefinedtypescript
describe('Component', () => {
it('should render correctly', () => {
// Arrange, Act, Assert pattern
});
});undefinedAPI Patterns
API模式
markdown
undefinedmarkdown
undefinedAPI Patterns
API Patterns
Route Handlers
Route Handlers
typescript
// Standard response format
return NextResponse.json({
data: result,
error: null,
meta: { timestamp: Date.now() }
});
// Error response
return NextResponse.json(
{ data: null, error: { code: 'NOT_FOUND', message: '...' } },
{ status: 404 }
);typescript
// Standard response format
return NextResponse.json({
data: result,
error: null,
meta: { timestamp: Date.now() }
});
// Error response
return NextResponse.json(
{ data: null, error: { code: 'NOT_FOUND', message: '...' } },
{ status: 404 }
);Validation
Validation
- Use Zod for request validation
- Validate early, fail fast
undefined- Use Zod for request validation
- Validate early, fail fast
undefinedDo's and Don'ts
注意事项(可做/不可做)
markdown
undefinedmarkdown
undefinedGuidelines
Guidelines
Do
Do
- Write self-documenting code
- Add JSDoc comments for public APIs
- Use meaningful variable names
- Write self-documenting code
- Add JSDoc comments for public APIs
- Use meaningful variable names
Don't
Don't
- Use type
any - Leave console.log in production code
- Commit sensitive data
undefined- Use type
any - Leave console.log in production code
- Commit sensitive data
undefinedFile Location
文件位置
The file must be at (not in root).
.github/copilot-instructions.md该文件必须放置在路径下(不能在根目录)。
.github/copilot-instructions.md