用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/diegosouzapw/awesome-omni-skill --skill ci-setup命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | ci-setup |
| description | Configure CI/CD pipelines for GitHub Actions, GitLab CI, CircleCI with best practices |
| disable-model-invocation | true |
I'll set up a production-ready CI/CD pipeline with automated testing, linting, and deployment workflows.
Supported Platforms:
Status: ✅ Fully Optimized (Phase 2 Batch 2, 2026-01-26)
Target Reduction: 60% (2,000-3,500 → 600-1,500 tokens)
1. Template-Based CI Generation (Primary: 1,200 token savings)
2. Git Provider Auto-Detection (300 token savings)
REMOTE=$(git remote get-url origin 2>/dev/null || echo "")
if echo "$REMOTE" | grep -q "github.com"; then CI_PLATFORM="github"
elif echo "$REMOTE" | grep -q "gitlab"; then CI_PLATFORM="gitlab"
fi
3. Early Exit for Existing CI (400 token savings)
.github/workflows/, .gitlab-ci.yml, .circleci/config.yml4. Project Type Detection Caching (200 token savings)
{
"projectType": "nodejs",
"framework": "nextjs",
"testCmd": "npm test",
"lintCmd": "npm run lint",
"buildCmd": "npm run build",
"packageManager": "npm",
"cachedAt": "2026-01-27T10:00:00Z",
"gitConfigHash": "abc123..."
}
.claude/cache/ci/platform-config.jsonpackage.json/pyproject.toml changes/test, /deploy-validate, /release-automation5. Incremental Pipeline Enhancement (300 token savings)
6. Bash-Only Placeholder Replacement (100 token savings)
sed commands for placeholder substitutionsed -i "s|TEST_CMD_PLACEHOLDER|$TEST_CMD|g" .github/workflows/ci.yml
sed -i "s|LINT_CMD_PLACEHOLDER|$LINT_CMD|g" .github/workflows/ci.yml
sed -i "s|BUILD_CMD_PLACEHOLDER|$BUILD_CMD|g" .github/workflows/ci.yml
| Scenario | Unoptimized | Optimized | Savings |
|---|---|---|---|
| New CI setup (GitHub Actions) | 2,500 | 800 | 68% |
| New CI setup (GitLab CI) | 2,800 | 900 | 68% |
| Existing CI detected (early exit) | 2,000 | 300 | 85% |
| Subsequent runs (cached) | 2,000 | 600 | 70% |
| Multiple platforms comparison | 3,500 | 1,500 | 57% |
| Average across all scenarios | 2,560 | 820 | 68% |
Real-World Distribution:
Effective Savings: 68% reduction vs. unoptimized baseline
Early Exit Check:
# Phase 0: Check for existing CI (50 tokens)
if [ -f ".github/workflows/ci.yml" ] || [ -f ".github/workflows/main.yml" ]; then
echo "⚠️ GitHub Actions CI already configured"
echo "Existing workflow: .github/workflows/ci.yml"
read -p "Overwrite existing configuration? (yes/no): " overwrite
if [ "$overwrite" != "yes" ]; then
echo "CI setup cancelled. Use /deploy-validate to verify existing pipeline."
exit 0
fi
fi
Cache Integration:
# Load or create cache (100 tokens with cache hit)
CACHE_FILE=".claude/cache/ci/platform-config.json"
mkdir -p .claude/cache/ci
if [ -f "$CACHE_FILE" ]; then
# Validate cache age and file hash
CACHED_AT=$(jq -r '.cachedAt' "$CACHE_FILE")
CACHE_AGE=$(( $(date +%s) - $(date -d "$CACHED_AT" +%s) ))
if [ $CACHE_AGE -lt 604800 ]; then
# Cache valid, load values
PROJECT_TYPE=$(jq -r '.projectType' "$CACHE_FILE")
TEST_CMD=$(jq -r '.testCmd' "$CACHE_FILE")
LINT_CMD=$(jq -r '.lintCmd' "$CACHE_FILE")
BUILD_CMD=$(jq -r '.buildCmd' "$CACHE_FILE")
echo "✓ Using cached project configuration"
fi
else
# Detect and cache
detect_project_type
save_cache
fi
Template Generation:
# Generate from template (500 tokens, no Read needed)
cat > .github/workflows/ci.yml << 'EOFGH'
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- run: npm ci
- run: TEST_CMD_PLACEHOLDER
- run: LINT_CMD_PLACEHOLDER
- run: BUILD_CMD_PLACEHOLDER
EOFGH
# Replace placeholders with bash (50 tokens)
sed -i "s|TEST_CMD_PLACEHOLDER|$TEST_CMD|g" .github/workflows/ci.yml
File: .claude/cache/ci/platform-config.json
Schema:
{
"version": "1.0.0",
"projectType": "nodejs",
"framework": "nextjs",
"testCmd": "npm test",
"lintCmd": "npm run lint",
"buildCmd": "npm run build",
"packageManager": "npm",
"hasDocker": false,
"hasTypeScript": true,
"nodeVersion": "20.x",
"pythonVersion": null,
"ciPlatform": "github",
"gitRemote": "git@github.com:user/repo.git",
"cachedAt": "2026-01-27T10:00:00Z"
Invalidation Triggers:
package.json modified (hash mismatch).git/config modified (platform change)rm -rf .claude/cache/ci/Shared Cache: Other skills can read this cache:
/test - Reuse test command detection/deploy-validate - Reuse build command and platform info/release-automation - Reuse CI platform for release workflows/e2e-generate - Reuse project type for E2E test setup1. Generated Config Validation (No Additional Tokens)
2. CI Platform Verification (100 tokens if needed)
3. Integration Testing
4. Cache Correctness
Token Usage Breakdown:
Unoptimized Baseline (2,000-3,500 tokens):
Optimized Flow (600-1,500 tokens):
Per-Run Savings:
Expected Cost per Month (100 projects):
Annual Savings: ~$30/year for typical usage patterns
For Existing Users:
--no-cache flagBackwards Compatibility:
Track These Metrics:
Success Criteria:
Optimization Status: ✅ All targets met (Phase 2 Batch 2, 2026-01-26)
# Detect CI platform efficiently
detect_ci_platform() {
# Check git remote for GitHub/GitLab
if [ -d ".git" ]; then
REMOTE=$(git remote get-url origin 2>/dev/null || echo "")
if echo "$REMOTE" | grep -q "github.com"; then
echo "github"
return 0
elif echo "$REMOTE" | grep -q "gitlab"; then
echo "gitlab"
return 0
fi
fi
# Check for existing CI configs
if [ -f ".github/workflows/ci.yml" ] || [ -f ".github/workflows/main.yml" ]; then
echo "github"
elif [ -f ".gitlab-ci.yml" ]; then
echo "gitlab"
elif [ -f ".circleci/config.yml" ]; then
echo "circle"
elif [ -f "Jenkinsfile" ]; then
echo "jenkins"
}
CI_PLATFORM=$(detect_ci_platform)
[ = ];
-p choice
1) CI_PLATFORM= ;;
2) CI_PLATFORM= ;;
3) CI_PLATFORM= ;;
4) CI_PLATFORM= ;;
*) ; 1 ;;
# Detect project type and testing tools
detect_project_type() {
if [ -f "package.json" ]; then
# Node.js project
if grep -q "\"next\"" package.json; then
echo "nextjs"
elif grep -q "\"react\"" package.json; then
echo "react"
elif grep -q "\"vue\"" package.json; then
echo "vue"
else
echo "nodejs"
fi
elif [ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
echo "python"
elif [ -f "go.mod" ]; then
echo "golang"
elif [ -f "Cargo.toml" ]; then
echo "rust"
elif [ -f "pom.xml" ]; then
echo "maven"
elif [ -f "build.gradle" ]; then
echo
}
PROJECT_TYPE=$(detect_project_type)
TEST_CMD=
LINT_CMD=
BUILD_CMD=
[ = ] || [ = ] || [ = ] || [ = ];
grep -q package.json;
TEST_CMD=
grep -q package.json;
LINT_CMD=
grep -q package.json;
BUILD_CMD=
[ = ];
TEST_CMD=
LINT_CMD=
BUILD_CMD=
[ = ];
TEST_CMD=
LINT_CMD=
BUILD_CMD=
if [ "$CI_PLATFORM" = "github" ]; then
mkdir -p .github/workflows
cat > .github/workflows/ci.yml << 'EOFGH'
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: LINT_CMD_PLACEHOLDER
if: always()
- name: Run tests
run: TEST_CMD_PLACEHOLDER
if: always()
- name: Build
run: BUILD_CMD_PLACEHOLDER
if: always()
- name: Upload coverage
uses: codecov/codecov-action@v3
if: matrix.node-version == '20.x'
with:
file: ./coverage/coverage-final.json
flags: unittests
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: LINT_CMD_PLACEHOLDER
build:
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build application
run: BUILD_CMD_PLACEHOLDER
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: dist/
retention-days: 7
EOFGH
# Replace placeholders
if [ ! -z "$LINT_CMD" ];
sed -i .github/workflows/ci.yml
sed -i .github/workflows/ci.yml
[ ! -z ];
sed -i .github/workflows/ci.yml
sed -i .github/workflows/ci.yml
[ ! -z ];
sed -i .github/workflows/ci.yml
sed -i .github/workflows/ci.yml
if [ "$CI_PLATFORM" = "gitlab" ]; then
cat > .gitlab-ci.yml << 'EOFGL'
stages:
- test
- build
- deploy
variables:
NODE_VERSION: "20"
before_script:
- node --version
- npm --version
cache:
paths:
- node_modules/
- .npm/
install_dependencies:
stage: .pre
script:
- npm ci --cache .npm --prefer-offline
artifacts:
paths:
- node_modules/
expire_in: 1 day
lint:
stage: test
dependencies:
- install_dependencies
script:
- LINT_CMD_PLACEHOLDER
test:
stage: test
dependencies:
- install_dependencies
script:
- TEST_CMD_PLACEHOLDER
coverage: '/Lines\s*:\s*(\d+\.\d+)%/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
build:
stage: build
dependencies:
- install_dependencies
script:
- BUILD_CMD_PLACEHOLDER
artifacts:
paths:
- dist/
expire_in: 1 week
pages:
stage: deploy
dependencies:
- build
script:
- mkdir -p public
- cp -r dist/* public/
artifacts:
paths:
- public
only:
- main
EOFGL
# Replace placeholders
if [ ! -z "$LINT_CMD" ]; then
sed -i "s|LINT_CMD_PLACEHOLDER|$LINT_CMD|g" .gitlab-ci.yml
else
sed -i "/LINT_CMD_PLACEHOLDER/d" .gitlab-ci.yml
sed -i "/^lint:/,/^$/d" .gitlab-ci.yml
fi
if [ ! -z "$TEST_CMD" ]; then
sed -i "s|TEST_CMD_PLACEHOLDER|$TEST_CMD|g" .gitlab-ci.yml
else
sed -i "/TEST_CMD_PLACEHOLDER/d" .gitlab-ci.yml
[ ! -z ];
sed -i .gitlab-ci.yml
sed -i .gitlab-ci.yml
if [ "$CI_PLATFORM" = "circle" ]; then
mkdir -p .circleci
cat > .circleci/config.yml << 'EOFCIRCLE'
version: 2.1
orbs:
node: circleci/node@5.1.0
jobs:
test:
docker:
- image: cimg/node:20.0
steps:
- checkout
- node/install-packages:
pkg-manager: npm
- run:
name: Run tests
command: TEST_CMD_PLACEHOLDER
- run:
name: Run linter
command: LINT_CMD_PLACEHOLDER
build:
docker:
- image: cimg/node:20.0
steps:
- checkout
- node/install-packages:
pkg-manager: npm
- run:
name: Build application
command: BUILD_CMD_PLACEHOLDER
- persist_to_workspace:
root: .
paths:
- dist
workflows:
test-and-build:
jobs:
- test
- build:
requires:
- test
EOFCIRCLE
# Replace placeholders
if [ ! -z "$TEST_CMD" ]; then
sed -i "s|TEST_CMD_PLACEHOLDER|$TEST_CMD|g" .circleci/config.yml
else
sed -i "/TEST_CMD_PLACEHOLDER/d" .circleci/config.yml
fi
if [ ! -z "$LINT_CMD" ]; then
sed -i "s|LINT_CMD_PLACEHOLDER|$LINT_CMD|g" .circleci/config.yml
else
sed -i "/LINT_CMD_PLACEHOLDER/d" .circleci/config.yml
fi
if [ ! -z "$BUILD_CMD" ]; then
sed -i .circleci/config.yml
sed -i .circleci/config.yml
echo ""
echo "=== Optional CI Enhancements ==="
echo ""
read -p "Add dependency caching? (yes/no): " add_cache
read -p "Add code coverage reporting? (yes/no): " add_coverage
read -p "Add security scanning? (yes/no): " add_security
read -p "Add Docker build? (yes/no): " add_docker
# Add enhancements based on selections
if [ "$add_security" = "yes" ]; then
echo ""
echo "Security scanning options:"
echo " - GitHub: CodeQL (automatic)"
echo " - Snyk: npm install -g snyk"
echo " - npm audit: Built-in"
echo ""
echo "Recommend adding: /dependency-audit and /secrets-scan skills"
fi
if [ "$add_docker" = "yes" ]; then
echo ""
echo "Docker integration:"
echo " 1. Create Dockerfile in project root"
echo " 2. Add Docker build step to CI"
echo " 3. Push to container registry"
# Generate status badge for README
echo ""
echo "=== CI Status Badge ==="
echo ""
echo "Add this badge to your README.md:"
echo ""
case $CI_PLATFORM in
github)
REPO_PATH=$(git remote get-url origin | sed 's/.*github.com[:/]\(.*\)\.git/\1/')
echo "[](https://github.com/$REPO_PATH/actions/workflows/ci.yml)"
;;
gitlab)
PROJECT_PATH=$(git remote get-url origin | sed 's/.*gitlab.com[:/]\(.*\)\.git/\1/')
echo "[](https://gitlab.com/$PROJECT_PATH/-/commits/main)"
;;
circle)
echo "[](https://circleci.com/gh/USERNAME/REPO)"
;;
esac
echo ""
echo "=== CI/CD Setup Complete! ==="
echo ""
echo "✓ Platform: $CI_PLATFORM"
echo "✓ Project type: $PROJECT_TYPE"
echo "✓ Configuration created"
echo ""
echo "📋 Pipeline stages:"
echo " 1. Lint: Code quality checks"
echo " 2. Test: Automated testing"
echo " 3. Build: Compile/bundle application"
echo ""
echo "🚀 Next steps:"
echo " 1. Commit CI configuration:"
echo " git add .github/ .gitlab-ci.yml .circleci/"
echo " git commit -m 'ci: Add CI/CD pipeline'"
echo " git push"
echo " 2. Verify pipeline runs successfully"
echo " 3. Configure deployment with /deploy-validate"
echo " 4. Add security scanning with /dependency-audit"
echo ""
echo "💡 Pro tips:"
echo " - Run 'npm test' locally before pushing"
echo " - Use '/test' skill for intelligent test execution"
/deploy-validate - Add deployment validation to pipeline/test - Run tests locally before CI/dependency-audit - Add security scanning to CI/e2e-generate - Add E2E tests to CI pipelineImportant Git Safety:
Credits: CI/CD patterns based on industry best practices from GitHub Actions, GitLab CI, and CircleCI documentation.