Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
552 changes: 552 additions & 0 deletions 01-slash-commands/README.zh-CN.md

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions 01-slash-commands/commit.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*), Bash(git diff:*)
argument-hint: [message]
description: 基于上下文创建 git commit
---

## 上下文

- 当前 git 状态: !`git status`
- 当前 git diff: !`git diff HEAD`
- 当前分支: !`git branch --show-current`
- 最近提交: !`git log --oneline -10`

## 你的任务

基于上述变更,创建一个单独的 git commit。

如果通过参数提供了消息,请使用它:$ARGUMENTS

否则请分析变更,并按 conventional commits 格式生成合适的 commit message:
- `feat:` 用于新功能
- `fix:` 用于 bug 修复
- `docs:` 用于文档变更
- `refactor:` 用于代码重构
- `test:` 用于新增测试
- `chore:` 用于维护性任务
24 changes: 24 additions & 0 deletions 01-slash-commands/doc-refactor.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Documentation Refactor
description: 为提升清晰度与可访问性而重构项目文档结构
tags: documentation, refactoring, organization
---

# Documentation Refactor

按项目类型调整并重构文档结构:

1. **分析项目**:识别类型(库/API/Web 应用/CLI/微服务)、架构与用户画像
2. **集中管理文档**:将技术文档归集到 `docs/`,并建立正确的交叉引用
3. **根 README.md**:精简为入口页,包含概览、快速开始、模块/组件摘要、许可证、联系方式
4. **组件文档**:为模块/包/服务补充 README,包含安装与测试说明
5. **按相关类别组织 `docs/`**:
- Architecture、API Reference、Database、Design、Troubleshooting、Deployment、Contributing(按项目需求调整)
6. **创建指南(按需选择)**:
- User Guide:面向应用终端用户
- API Documentation:面向 API,含端点、认证、示例
- Development Guide:开发环境、测试、贡献流程
- Deployment Guide:服务/应用的生产部署
7. **所有图表统一使用 Mermaid**(架构图、流程图、模式图)

保持文档简洁、可快速扫描,并与项目类型保持上下文一致。
19 changes: 19 additions & 0 deletions 01-slash-commands/generate-api-docs.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
description: 从源码生成完整 API 文档
---

# API Documentation Generator

按以下步骤生成 API 文档:

1. 扫描 `/src/api/` 下所有文件
2. 提取函数签名与 JSDoc 注释
3. 按 endpoint/module 组织内容
4. 生成包含示例的 Markdown
5. 包含 request/response schema
6. 补充错误文档

输出格式:
- 在 `/docs/api.md` 生成 Markdown 文件
- 为所有 endpoint 提供 curl 示例
- 补充 TypeScript 类型
19 changes: 19 additions & 0 deletions 01-slash-commands/optimize.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
description: 分析代码中的性能问题并给出优化建议
---

# Code Optimization

请按以下优先级依次审查所提供代码:

1. **性能瓶颈** - 识别 O(n²) 操作、低效循环
2. **内存泄漏** - 查找未释放资源、循环引用
3. **算法改进** - 建议更优算法或数据结构
4. **缓存机会** - 识别重复计算
5. **并发问题** - 查找竞态条件或线程问题

请按以下结构输出:
- 问题严重级别(Critical/High/Medium/Low)
- 代码位置
- 问题说明
- 推荐修复方案(含代码示例)
26 changes: 26 additions & 0 deletions 01-slash-commands/pr.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
description: 清理代码、暂存变更并准备 Pull Request
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git diff:*), Bash(npm test:*), Bash(npm run lint:*)
---

# Pull Request Preparation Checklist

在创建 PR 前,执行以下步骤:

1. 运行格式化:`prettier --write .`
2. 运行测试:`npm test`
3. 检查 git diff:`git diff HEAD`
4. 暂存变更:`git add .`
5. 使用 conventional commits 规范编写提交信息:
- `fix:` bug 修复
- `feat:` 新功能
- `docs:` 文档变更
- `refactor:` 代码重构
- `test:` 测试新增
- `chore:` 维护任务

6. 生成 PR 摘要,至少包含:
- 变更内容
- 变更原因
- 已执行测试
- 可能影响
151 changes: 151 additions & 0 deletions 01-slash-commands/push-all.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
description: 暂存全部变更、创建 commit 并推送到远端(请谨慎使用)
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*), Bash(git push:*), Bash(git diff:*), Bash(git log:*), Bash(git pull:*)
---

# Commit and Push Everything

⚠️ **注意**:该命令会暂存**全部**变更、提交并推送到远端。仅在你确认所有变更应一并提交时使用。

## Workflow

### 1. 分析变更
并行运行:
- `git status` - 查看修改/新增/删除/未跟踪文件
- `git diff --stat` - 查看变更统计
- `git log -1 --oneline` - 查看最近提交风格

### 2. 安全检查

**❌ 若发现以下内容,必须停止并警告:**
- Secrets: `.env*`, `*.key`, `*.pem`, `credentials.json`, `secrets.yaml`, `id_rsa`, `*.p12`, `*.pfx`, `*.cer`
- API Keys: 任意 `*_API_KEY`, `*_SECRET`, `*_TOKEN` 且为真实值(非占位,如 `your-api-key`, `xxx`, `placeholder`)
- 大文件:未使用 Git LFS 且 `>10MB`
- 构建产物:`node_modules/`, `dist/`, `build/`, `__pycache__/`, `*.pyc`, `.venv/`
- 临时文件:`.DS_Store`, `thumbs.db`, `*.swp`, `*.tmp`

**API Key 校验示例:**
```bash
OPENAI_API_KEY=sk-proj-xxxxx # ❌ 检测到真实 key
AWS_SECRET_KEY=AKIA... # ❌ 检测到真实 key
STRIPE_API_KEY=sk_live_... # ❌ 检测到真实 key

# ✅ 可接受占位符:
API_KEY=your-api-key-here
SECRET_KEY=placeholder
TOKEN=xxx
API_KEY=<your-key>
SECRET=${YOUR_SECRET}
```

**✅ 同时确认:**
- `.gitignore` 配置正确
- 无 merge conflict
- 分支正确(在 main/master 上要警告)
- API key 仅为占位符

### 3. 请求用户确认

展示摘要:
```text
📊 Changes Summary:
- X files modified, Y added, Z deleted
- Total: +AAA insertions, -BBB deletions

🔒 Safety: ✅ No secrets | ✅ No large files | ⚠️ [warnings]
🌿 Branch: [name] → origin/[name]

I will: git add . → commit → push

Type 'yes' to proceed or 'no' to cancel.
```

**必须等待用户明确输入 `yes` 才可继续。**

### 4. 执行(确认后)

按顺序执行:
```bash
git add .
git status # 校验暂存结果
```

### 5. 生成提交信息

分析变更后,按 conventional commit 生成:

**格式:**
```text
[type]: Brief summary (max 72 characters)

- Key change 1
- Key change 2
- Key change 3
```

**类型:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `perf`, `build`, `ci`

**示例:**
```text
docs: Update concept README files with comprehensive documentation

- Add architecture diagrams and tables
- Include practical examples
- Expand best practices sections
```

### 6. 提交并推送

```bash
git commit -m "$(cat <<'EOF'
[Generated commit message]
EOF
)"
git push # 若失败: git pull --rebase && git push
git log -1 --oneline --decorate # 校验结果
```

### 7. 成功确认

```text
✅ Successfully pushed to remote!

Commit: [hash] [message]
Branch: [branch] → origin/[branch]
Files changed: X (+insertions, -deletions)
```

## Error Handling

- **git add 失败**:检查权限、锁定文件、仓库是否已初始化
- **git commit 失败**:修复 pre-commit hooks,检查 git 配置(user.name/email)
- **git push 失败**:
- Non-fast-forward: `git pull --rebase && git push`
- 无远端分支: `git push -u origin [branch]`
- 受保护分支: 改为 PR 流程

## 何时使用

✅ **适合:**
- 多文件文档更新
- 功能 + 测试 + 文档一体提交
- 跨文件 bug 修复
- 项目级格式化/重构
- 配置类统一变更

❌ **不适合:**
- 不确定要提交哪些改动
- 包含敏感信息
- 受保护分支且未评审
- 有冲突未解决
- 想保留细粒度提交历史
- pre-commit hooks 仍失败

## 替代方案

如用户希望更可控,建议:
1. **选择性暂存**:仅暂存指定文件
2. **交互式暂存**:`git add -p` 按 patch 选择
3. **PR 流程**:建分支 → 推送 → 发 PR(可配合 `/pr`)

**⚠️ 牢记**:推送前务必审查变更。不确定时,请使用逐条 git 命令而非一次性全推送。
25 changes: 25 additions & 0 deletions 01-slash-commands/setup-ci-cd.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Setup CI/CD Pipeline
description: 实现 pre-commit hooks 与 GitHub Actions 质量保障流程
tags: ci-cd, devops, automation
---

# Setup CI/CD Pipeline

按项目类型实现完整 DevOps 质量门禁:

1. **分析项目**:识别语言、框架、构建系统与现有工具链
2. **配置 pre-commit hooks**(按语言匹配工具):
- Formatting: Prettier/Black/gofmt/rustfmt 等
- Linting: ESLint/Ruff/golangci-lint/Clippy 等
- Security: Bandit/gosec/cargo-audit/npm audit 等
- Type checking: TypeScript/mypy/flow(如适用)
- Tests: 运行相关测试集
3. **创建 GitHub Actions workflows**(`.github/workflows/`):
- 在 push/PR 中镜像 pre-commit 检查
- 多版本/多平台矩阵(如适用)
- 构建与测试校验
- 部署步骤(如需要)
4. **验证流水线**:本地测试、创建测试 PR、确认所有检查通过

优先使用免费/开源工具。尊重现有配置。保持执行速度。
25 changes: 25 additions & 0 deletions 01-slash-commands/unit-test-expand.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Expand Unit Tests
description: 通过覆盖未测试分支与边界场景提升测试覆盖率
tags: testing, coverage, unit-tests
---

# Expand Unit Tests

按项目测试框架扩展现有单元测试:

1. **分析覆盖率**:运行覆盖率报告,定位未覆盖分支、边界场景与低覆盖区域
2. **识别缺口**:检查逻辑分支、错误路径、边界条件、空值/空输入
3. **按项目框架编写测试**:
- Jest/Vitest/Mocha(JavaScript/TypeScript)
- pytest/unittest(Python)
- Go testing/testify(Go)
- Rust test framework(Rust)
4. **聚焦关键场景**:
- 错误处理与异常路径
- 边界值(最小/最大、空、null)
- 极端与角落场景
- 状态迁移与副作用
5. **验证提升**:再次运行覆盖率,确认覆盖率有可量化增长

仅输出新增测试代码块。遵循现有测试模式与命名规范。
Loading