关于 copilot-docs
copilot-docs 是用于配置 GitHub Copilot 仓库级指令的技能。它说明如何编写项目背景、代码规范、命名、测试和 API 模式,并指定指令文件的位置。
主要功能
- 01配置仓库级 Copilot 指令
- 02编写项目技术栈背景
- 03制定代码与命名规范
- 04记录测试和 API 模式
- 05指定指令文件路径
适用场景
- 01为仓库设置 Copilot 行为指南
- 02统一项目代码风格要求
- 03向 Copilot 提供测试约定
- 04记录项目 API 处理规范
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ hoodini/ ai-agents-skills --skill copilot-docs安装后在 Claude Code 中输入/copilot-docs确认已加载。
详细介绍
GitHub Copilot 自定义指令
为 GitHub Copilot 配置仓库专属指令。
快速入门
在你的仓库中创建 .github/copilot-instructions.md:
# Copilot Instructions
## Code Style
- Use TypeScript with strict mode
- Prefer functional components with hooks
- Use Tailwind CSS for styling
## Project Context
This is a Next.js 14 app using the App Router.
API routes are in `app/api/`.
有效模式
项目背景
# Project Context
## Tech Stack
- Next.js 14 with App Router
- TypeScript 5.3+
- Tailwind CSS 3.4
- Prisma ORM with PostgreSQL
## Architecture
- `app/` - Next.js App Router pages and API routes
- `components/` - React components
- `lib/` - Utility functions and shared code
- `prisma/` - Database schema and migrations
代码规范
# Code Standards
## TypeScript
- Enable strict mode
- Prefer `interface` over `type` for object shapes
- Use explicit return types on functions
## React
- Use functional components exclusively
- Prefer named exports
- Extract hooks to `hooks/` directory
## Error Handling
- Use Result pattern for fallible operations
- Always handle async errors with try/catch
- Log errors with structured format
命名约定
# Naming Conventions
## Files
- Components: PascalCase (Button.tsx)
- Utilities: camelCase (formatDate.ts)
- Constants: SCREAMING_SNAKE_CASE
## Code
- Boolean variables: is*, has*, should* prefix
- Event handlers: handle* prefix (handleClick)
- Async functions: *Async suffix
测试
# Testing Guidelines
## Unit Tests
- Use Vitest for unit testing
- Place tests next to source files (*.test.ts)
- Mock external dependencies
## Test Patterns
```typescript
describe('Component', () => {
it('should render correctly', () => {
// Arrange, Act, Assert pattern
});
});
### API Patterns
```markdown
# API Patterns
## 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 }
);
验证
- 使用 Zod 验证请求
- 尽早验证,快速失败
### Do's and Don'ts
```markdown
# Guidelines
## Do
- Write self-documenting code
- Add JSDoc comments for public APIs
- Use meaningful variable names
## Don't
- Use `any` type
- Leave console.log in production code
- Commit sensitive data
文件位置
文件必须位于 .github/copilot-instructions.md(而不是根目录)。
资源
评论
支持 Markdown