关于 contributing-guide
面向开源项目贡献者文档编写的 Skill,涵盖环境设置、Git 规范、代码审查和社区指南,并提供可复用的 CONTRIBUTING.md 结构与示例。
主要功能
- 01CONTRIBUTING.md 结构
- 02开发环境配置示例
- 03Git 分支与提交规范
- 04PR 与问题模板
- 05代码审查和风格指南
适用场景
- 01起草贡献指南
- 02记录环境设置与测试步骤
- 03统一 PR 和问题格式
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ dengineproblem/ agents-monorepo --skill contributing-guide安装后在 Claude Code 中输入/contributing-guide确认已加载。
详细介绍
贡献指南专家
面向开源贡献者的文档专家。
CONTRIBUTING.md 的结构
# Contributing to Project Name
Thank you for your interest in contributing! 🎉
## Table of Contents
- [Code of Conduct](#code-of-conduct)
- [Getting Started](#getting-started)
- [Development Setup](#development-setup)
- [How to Contribute](#how-to-contribute)
- [Pull Request Process](#pull-request-process)
- [Style Guide](#style-guide)
- [Community](#community)
快速入门部分
## Quick Start
1. Fork the repository
2. Clone your fork:
```bash
git clone https://github.com/YOUR_USERNAME/project-name.git
cd project-name
- 安装依赖:
npm install - 创建分支:
git checkout -b feature/your-feature-name - 修改并测试:
npm test - 提交 PR!
## Development Environment
```markdown
## Development Setup
### Prerequisites
- Node.js 18+ ([download](https://nodejs.org))
- npm 8+ or yarn 1.22+
- Git 2.28+
- Docker (optional, for integration tests)
### Installation
```bash
# Clone repository
git clone https://github.com/org/project.git
cd project
# Install dependencies
npm install
# Copy environment file
cp .env.example .env
# Run setup script
npm run setup
# Verify installation
npm test
可用脚本
| 命令 | 描述 |
|---|---|
npm run dev | 启动开发服务器 |
npm test | 运行所有测试 |
npm run test:watch | 以监视模式运行测试 |
npm run lint | 运行 ESLint |
npm run lint:fix | 修复 lint 问题 |
npm run typecheck | 运行 TypeScript 检查 |
npm run build | 构建生产版本 |
## Git Workflow
```markdown
## Git Workflow
### Branch Naming Convention
/
**Types:**
- `feature/` - New features
- `fix/` - Bug fixes
- `docs/` - Documentation only
- `refactor/` - Code refactoring
- `test/` - Adding tests
- `chore/` - Maintenance tasks
**Examples:**
- `feature/user-authentication`
- `fix/login-redirect-loop`
- `docs/api-examples`
### Commit Messages
We follow [Conventional Commits](https://conventionalcommits.org):
():
[optional body]
[optional footer(s)]
**Types:**
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation
- `style`: Formatting (no code change)
- `refactor`: Code refactoring
- `test`: Adding tests
- `chore`: Maintenance
**Examples:**
feat(auth): add OAuth2 support fix(api): handle null response from server docs(readme): update installation steps
拉取请求模板
## Pull Request Guidelines
### Before Submitting
- [ ] I have read the [Contributing Guide](CONTRIBUTING.md)
- [ ] My code follows the project's style guidelines
- [ ] I have performed a self-review
- [ ] I have added tests for my changes
- [ ] All new and existing tests pass
- [ ] I have updated documentation if needed
- [ ] My commits follow conventional commit format
### PR Template
```markdown
## Description
## Type of Change
- [ ] Bug fix (non-breaking change)
- [ ] New feature (non-breaking change)
- [ ] Breaking change
- [ ] Documentation update
## How Has This Been Tested?
## Screenshots (if applicable)
## Checklist
- [ ] Tests pass
- [ ] Lint passes
- [ ] Documentation updated
## Issue Templates
### Bug Report
```markdown
---
name: Bug Report
about: Report a bug to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---
## Bug Description
## Steps to Reproduce
1. Go to '...'
2. Click on '...'
3. See error
## Expected Behavior
## Actual Behavior
## Environment
- OS: [e.g., macOS 14.0]
- Node version: [e.g., 18.17.0]
- Project version: [e.g., 1.2.3]
## Screenshots
## Additional Context
功能请求
---
name: Feature Request
about: Suggest a new feature
title: '[FEATURE] '
labels: enhancement
assignees: ''
---
## Problem Statement
## Proposed Solution
## Alternatives Considered
## Additional Context
代码风格指南
## Style Guide
### General Principles
- Write self-documenting code
- Prefer explicit over implicit
- Keep functions small and focused
- DRY (Don't Repeat Yourself)
### TypeScript/JavaScript
```typescript
// ✅ Good
function calculateTotalPrice(items: CartItem[]): number {
return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}
// ❌ Bad
function calc(i: any[]): any {
let t = 0;
for (let x of i) t += x.p * x.q;
return t;
}
命名约定
| 类型 | 约定 | 示例 |
|---|---|---|
| 变量 | camelCase | userName |
| 函数 | camelCase | getUserById |
| 类 | PascalCase | UserService |
| 常量 | UPPER_SNAKE | MAX_RETRIES |
| 文件 | kebab-case | user-service.ts |
| 接口 | PascalCase + I 前缀 | IUserService |
文件结构
src/
├── components/ # UI components
├── hooks/ # Custom React hooks
├── services/ # Business logic
├── utils/ # Helper functions
├── types/ # TypeScript types
└── __tests__/ # Test files
## Code Review Process
```markdown
## Code Review
### Review Checklist
**Functionality:**
- [ ] Code works as intended
- [ ] Edge cases handled
- [ ] Error handling adequate
**Code Quality:**
- [ ] Readable and maintainable
- [ ] No unnecessary complexity
- [ ] Follows project conventions
**Testing:**
- [ ] Adequate test coverage
- [ ] Tests are meaningful
- [ ] Edge cases tested
**Security:**
- [ ] No hardcoded secrets
- [ ] Input validation present
- [ ] No SQL injection risks
### Response Times
- First response: within 48 hours
- Follow-up reviews: within 24 hours
- Merge after approval: within 24 hours
### Approval Requirements
- 1 maintainer approval required
- All CI checks must pass
- No unresolved conversations
提交前钩子
// package.json
{
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md}": [
"prettier --write"
]
}
}
认可计划
## Recognition
### Contributors
All contributors are added to our [CONTRIBUTORS.md](CONTRIBUTORS.md) file.
### Badges
| Badge | Criteria |
|-------|----------|
| 🥇 First Contribution | Merged first PR |
| 🔥 Frequent Contributor | 10+ merged PRs |
| 📚 Documentation Hero | 5+ docs PRs |
| 🐛 Bug Hunter | 5+ bug fixes |
| ⭐ Core Contributor | Significant impact |
### Rewards
- Stickers and swag for active contributors
- Shoutouts in release notes
- Conference ticket opportunities
- LinkedIn recommendations
社区指南
## Community
### Communication Channels
- **Discord**: [Join our server](https://discord.gg/xxx)
- **GitHub Discussions**: For questions and ideas
- **Twitter**: [@project](https://twitter.com/project)
### Response Time Expectations
- Issues: 48 hours
- PRs: 72 hours
- Questions: 24-48 hours
### Getting Help
1. Check existing issues and discussions
2. Read the documentation
3. Ask in Discord #help channel
4. Create a GitHub Discussion
### Code of Conduct
We follow the [Contributor Covenant](https://contributor-covenant.org).
Be respectful, inclusive, and constructive.
最佳实践
- 循序渐进 — 从简单到复杂
- 清晰的示例 — 真实的代码示例
- 保持最新 — 随变更更新
- 友好的语气 — 使用友好的语言
- 多个入口 — 面向不同类型的贡献
- 自动化检查 — 使用 CI 验证 PR
评论
支持 Markdown