aif-ci
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCI — Pipeline Configuration Generator
CI — 流水线配置生成器
Analyze a project and generate production-grade CI/CD pipeline configuration for GitHub Actions or GitLab CI. Generates separate jobs for linting, static analysis, tests, and security scanning — adapted to the project's language, framework, and existing tooling.
Three modes based on what exists:
| What exists | Mode | Action |
|---|---|---|
| No CI config | | Create pipeline from scratch with interactive setup |
| CI config exists but incomplete | | Audit & improve, add missing jobs |
| Full CI config | | Audit against best practices, fix gaps |
分析项目并生成适用于GitHub Actions或GitLab CI的生产级CI/CD流水线配置。针对项目的语言、框架和现有工具,生成独立的代码检查、静态分析、测试和安全扫描任务。
基于现有状态的三种模式:
| 现有状态 | 模式 | 操作 |
|---|---|---|
| 无CI配置 | | 通过交互式设置从头创建流水线 |
| CI配置存在但不完整 | | 审核并改进配置,添加缺失任务 |
| 完整CI配置 | | 对照最佳实践审核配置,修复漏洞 |
Step 0: Load Project Context
步骤0:加载项目上下文
Read the project description if available:
Read .ai-factory/DESCRIPTION.mdStore project context for later steps. If absent, Step 2 detects everything.
Read — MANDATORY if the file exists.
.ai-factory/skill-context/aif-ci/SKILL.mdThis file contains project-specific rules accumulated by from patches,
codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
/aif-evolveHow to apply skill-context rules:
- Treat them as project-level overrides for this skill's general instructions
- When a skill-context rule conflicts with a general rule written in this SKILL.md, the skill-context rule wins (more specific context takes priority — same principle as nested CLAUDE.md files)
- When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
- Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults — they exist because the project's experience proved the default insufficient
- CRITICAL: skill-context rules apply to ALL outputs of this skill — including generated CI workflow files and audit reports. Templates in this skill are base structures. If a skill-context rule says "CI MUST include step X" or "workflow MUST have job Y" — you MUST augment the templates accordingly. Generating CI config that violates skill-context rules is a bug.
Enforcement: After generating any output artifact, verify it against all skill-context rules.
If any rule is violated — fix the output before presenting it to the user.
若有项目描述则读取:
Read .ai-factory/DESCRIPTION.md保存项目上下文供后续步骤使用。若不存在该文件,步骤2将自动检测所有信息。
读取 — 若文件存在则为必填项。
.ai-factory/skill-context/aif-ci/SKILL.md该文件包含由从补丁、代码库约定和技术栈分析中积累的项目特定规则,这些规则是为当前项目量身定制的。
/aif-evolve如何应用技能上下文规则:
- 将其视为本技能通用指令的项目级覆盖规则
- 当技能上下文规则与本SKILL.md中的通用规则冲突时,技能上下文规则优先(更具体的上下文优先级更高 — 与嵌套CLAUDE.md文件的原则相同)
- 无冲突时,同时应用SKILL.md的通用规则和技能上下文的项目规则
- 即使技能上下文规则看似与本技能默认设置矛盾,也不得忽略 — 这些规则存在是因为项目实践证明默认设置不足
- 关键要求: 技能上下文规则适用于本技能的所有输出 — 包括生成的CI工作流文件和审核报告。本技能中的模板是基础结构。若技能上下文规则规定“CI必须包含步骤X”或“工作流必须有任务Y” — 必须相应扩充模板。生成违反技能上下文规则的CI配置属于错误。
执行要求: 生成任何输出工件后,需对照所有技能上下文规则验证。若违反任何规则 — 在呈现给用户前修复输出内容。
Step 1: Detect Existing CI & Determine Mode
步骤1:检测现有CI并确定模式
1.1 Scan for Existing CI Configuration
1.1 扫描现有CI配置
Glob: .github/workflows/*.yml, .github/workflows/*.yaml, .gitlab-ci.yml, .circleci/config.yml, Jenkinsfile, .travis.yml, bitbucket-pipelines.ymlClassify found files:
- :
HAS_GITHUB_ACTIONScontains YAML files.github/workflows/ - :
HAS_GITLAB_CIexists.gitlab-ci.yml - : CircleCI, Jenkins, Travis, or Bitbucket detected
HAS_OTHER_CI
Glob: .github/workflows/*.yml, .github/workflows/*.yaml, .gitlab-ci.yml, .circleci/config.yml, Jenkinsfile, .travis.yml, bitbucket-pipelines.yml对找到的文件进行分类:
- :
HAS_GITHUB_ACTIONS目录下存在YAML文件.github/workflows/ - :
HAS_GITLAB_CI文件存在.gitlab-ci.yml - : 检测到CircleCI、Jenkins、Travis或Bitbucket配置
HAS_OTHER_CI
1.2 Determine Mode
1.2 确定模式
If contains -> set regardless.
$ARGUMENTS--enhanceMODE = "enhance"Path A: No CI config exists ():
!HAS_GITHUB_ACTIONS && !HAS_GITLAB_CI && !HAS_OTHER_CI- Set
MODE = "generate" - Proceed to Step 1.3: Interactive Setup
Path B: CI config exists but is incomplete (e.g., has only tests, no linting):
- Set
MODE = "enhance" - Read all existing CI files -> store as
EXISTING_CONTENT - Log: "Found existing CI configuration. Will analyze and add missing jobs."
Path C: Full CI setup (has linting + tests + static analysis):
- Set
MODE = "audit" - Read all existing CI files -> store as
EXISTING_CONTENT - Log: "Found complete CI setup. Will audit against best practices and fix gaps."
若包含 -> 无论其他情况,设置
$ARGUMENTS--enhanceMODE = "enhance"路径A:无CI配置 ():
!HAS_GITHUB_ACTIONS && !HAS_GITLAB_CI && !HAS_OTHER_CI- 设置
MODE = "generate" - 进入步骤1.3:交互式设置
路径B:CI配置存在但不完整(例如仅包含测试,无代码检查):
- 设置
MODE = "enhance" - 读取所有现有CI文件 -> 保存为
EXISTING_CONTENT - 日志:"检测到现有CI配置。将分析并添加缺失任务。"
路径C:完整CI配置(包含代码检查 + 测试 + 静态分析):
- 设置
MODE = "audit" - 读取所有现有CI文件 -> 保存为
EXISTING_CONTENT - 日志:"检测到完整CI配置。将对照最佳实践审核并修复漏洞。"
1.3 Interactive Setup (Generate Mode Only)
1.3 交互式设置(仅生成模式)
Determine CI platform from or ask:
$ARGUMENTSIf contains -> set
If contains -> set
$ARGUMENTSgithubPLATFORM = "github"$ARGUMENTSgitlabPLATFORM = "gitlab"Otherwise:
AskUserQuestion: Which CI/CD platform do you use?
Options:
1. GitHub Actions (Recommended) — .github/workflows/*.yml
2. GitLab CI — .gitlab-ci.ymlAsk about optional features:
AskUserQuestion: Which additional CI features do you need?
Options (multiSelect):
1. Security scanning — Dependency audit, SAST
2. Coverage reporting — Upload test coverage
3. Matrix builds — Test across multiple language versions
4. None — Just linting, static analysis, and testsStore choices:
- : github | gitlab
PLATFORM - : boolean
WANT_SECURITY - : boolean
WANT_COVERAGE - : boolean
WANT_MATRIX
从中确定CI平台,或询问用户:
$ARGUMENTS若包含 -> 设置
若包含 -> 设置
$ARGUMENTSgithubPLATFORM = "github"$ARGUMENTSgitlabPLATFORM = "gitlab"否则:
AskUserQuestion: 您使用哪个CI/CD平台?
选项:
1. GitHub Actions(推荐) — .github/workflows/*.yml
2. GitLab CI — .gitlab-ci.yml询问可选功能:
AskUserQuestion: 您需要哪些额外的CI功能?
选项(可多选):
1. 安全扫描 — 依赖项审核、SAST
2. 覆盖率报告 — 上传测试覆盖率
3. 矩阵构建 — 跨多个语言版本测试
4. 无 — 仅需代码检查、静态分析和测试保存选择:
- : github | gitlab
PLATFORM - : 布尔值
WANT_SECURITY - : 布尔值
WANT_COVERAGE - : 布尔值
WANT_MATRIX
1.4 Read Existing Files (Enhance / Audit Modes)
1.4 读取现有文件(增强/审核模式)
Read all existing CI files and store as :
EXISTING_CONTENT- All files
.github/workflows/*.yml .gitlab-ci.yml- Any included GitLab CI files (check directives)
include:
Determine from existing files.
PLATFORM读取所有现有CI文件并保存为:
EXISTING_CONTENT- 所有文件
.github/workflows/*.yml - 文件
.gitlab-ci.yml - 所有被GitLab CI包含的文件(检查指令)
include:
从现有文件中确定。
PLATFORMStep 2: Deep Project Analysis
步骤2:深度项目分析
Scan the project thoroughly — every decision in the generated pipeline depends on this profile.
全面扫描项目 — 生成流水线的每个决策都依赖于此分析结果。
2.1 Language & Runtime
2.1 语言与运行时
| File | Language |
|---|---|
| PHP |
| Node.js / TypeScript |
| Python |
| Go |
| Rust |
| Java (Maven) |
| Java/Kotlin (Gradle) |
| 文件 | 语言 |
|---|---|
| PHP |
| Node.js / TypeScript |
| Python |
| Go |
| Rust |
| Java(Maven) |
| Java/Kotlin(Gradle) |
2.2 Language Version
2.2 语言版本
Detect the project's language version to use in CI:
| Language | Version Source | Example |
|---|---|---|
| PHP | | |
| Node.js | | |
| Python | | |
| Go | | |
| Rust | | |
| Java | | |
For matrix builds: use the minimum version from the project config as the lowest, and include the latest stable version. For non-matrix builds: use the latest version that satisfies the constraint.
检测项目使用的语言版本以用于CI:
| 语言 | 版本来源 | 示例 |
|---|---|---|
| PHP | | |
| Node.js | | |
| Python | | |
| Go | | |
| Rust | | |
| Java | | |
对于矩阵构建:使用项目配置中的最低版本作为下限,并包含最新稳定版本。对于非矩阵构建:使用满足约束的最新版本。
2.3 Package Manager & Lock File
2.3 包管理器与锁定文件
| File | Package Manager | Install Command |
|---|---|---|
| Composer | |
| Bun | |
| pnpm | |
| Yarn | |
| npm | |
| uv | |
| Poetry | |
| Pipenv | |
| pip | |
| Go modules | |
| Cargo | (built-in) |
Store: , , .
PACKAGE_MANAGERLOCK_FILEINSTALL_CMD| 文件 | 包管理器 | 安装命令 |
|---|---|---|
| Composer | |
| Bun | |
| pnpm | |
| Yarn | |
| npm | |
| uv | |
| Poetry | |
| Pipenv | |
| pip | |
| Go modules | |
| Cargo | (内置) |
保存:, , 。
PACKAGE_MANAGERLOCK_FILEINSTALL_CMD2.4–2.7 Tool Detection
2.4–2.7 工具检测
Detect project tools by scanning config files and dependencies. For the complete tool-to-command mapping → read
references/TOOL-COMMANDS.mdCategories: Linters & Formatters (PHP-CS-Fixer, ESLint, Prettier, Biome, Ruff, golangci-lint, clippy, Checkstyle), Static Analysis (PHPStan, Psalm, Rector, mypy, tsc), Test Frameworks (PHPUnit, Pest, Jest, Vitest, pytest, go test, cargo test) with coverage flags, Security Audit (composer audit, npm audit, pip-audit, govulncheck, cargo audit).
通过扫描配置文件和依赖项检测项目工具。完整的工具-命令映射 → 阅读
references/TOOL-COMMANDS.md分类:代码检查器与格式化工具(PHP-CS-Fixer、ESLint、Prettier、Biome、Ruff、golangci-lint、clippy、Checkstyle)、静态分析工具(PHPStan、Psalm、Rector、mypy、tsc)、测试框架(PHPUnit、Pest、Jest、Vitest、pytest、go test、cargo test)及覆盖率参数、安全审核工具(composer audit、npm audit、pip-audit、govulncheck、cargo audit)。
2.8 Services Detection
2.8 服务检测
Check if tests require external services (database, Redis, etc.):
Grep in tests/: postgres|mysql|redis|mongo|rabbitmq|elasticsearch
Glob: docker-compose.test.yml, docker-compose.ci.ymlIf services are needed, they will be configured in the CI pipeline as service containers.
检查测试是否需要外部服务(数据库、Redis等):
Grep in tests/: postgres|mysql|redis|mongo|rabbitmq|elasticsearch
Glob: docker-compose.test.yml, docker-compose.ci.yml若需要服务,将在CI流水线中配置为服务容器。
2.9 Build Output
2.9 构建输出
Does the project have a build step?
| Language | Has Build | Build Command |
|---|---|---|
Node.js (with | Yes | |
| Go | Yes | |
| Rust | Yes | |
| Java | Yes | |
| PHP | Usually no | — |
| Python | Usually no | — |
项目是否包含构建步骤?
| 语言 | 是否需要构建 | 构建命令 |
|---|---|---|
Node.js(含 | 是 | |
| Go | 是 | |
| Rust | 是 | |
| Java | 是 | |
| PHP | 通常不需要 | — |
| Python | 通常不需要 | — |
Summary
总结
Build :
PROJECT_PROFILE- ,
language,language_version(for matrix)language_versions - ,
package_manager,lock_fileinstall_cmd - : list of {name, command, config_file}
linters - : list of {name, command}
static_analyzers - ,
test_framework,test_cmdcoverage_cmd - : list of {name, command}
security_tools - ,
has_build_stepbuild_cmd - : boolean (for typecheck job)
has_typescript - : list of services for CI
services_needed - : main source directory (src/, app/, lib/)
source_dir
构建:
PROJECT_PROFILE- ,
language,language_version(用于矩阵构建)language_versions - ,
package_manager,lock_fileinstall_cmd - : {名称, 命令, 配置文件}列表
linters - : {名称, 命令}列表
static_analyzers - ,
test_framework,test_cmdcoverage_cmd - : {名称, 命令}列表
security_tools - ,
has_build_stepbuild_cmd - : 布尔值(用于类型检查任务)
has_typescript - : CI所需服务列表
services_needed - : 主源码目录(src/, app/, lib/)
source_dir
Step 3: Read Best Practices & Templates
步骤3:读取最佳实践与模板
Read skills/ci/references/BEST-PRACTICES.mdSelect templates matching the platform and language:
GitHub Actions:
| Language | Template |
|---|---|
| PHP | |
| Node.js | |
| Python | |
| Go | |
| Rust | |
| Java | |
GitLab CI:
| Language | Template |
|---|---|
| PHP | |
| Node.js | |
| Python | |
| Go | |
| Rust | |
| Java | |
Read the selected template:
Read skills/ci/templates/<platform>/<language>.ymlRead skills/ci/references/BEST-PRACTICES.md选择匹配平台和语言的模板:
GitHub Actions:
| 语言 | 模板 |
|---|---|
| PHP | |
| Node.js | |
| Python | |
| Go | |
| Rust | |
| Java | |
GitLab CI:
| 语言 | 模板 |
|---|---|
| PHP | |
| Node.js | |
| Python | |
| Go | |
| Rust | |
| Java | |
读取选中的模板:
Read skills/ci/templates/<platform>/<language>.ymlStep 4: Generate Pipeline (Generate Mode)
步骤4:生成流水线(生成模式)
Using the , best practices, and template as a base, generate a customized CI pipeline.
PROJECT_PROFILE以、最佳实践和模板为基础,生成定制化CI流水线。
PROJECT_PROFILE4.1 GitHub Actions Generation
4.1 GitHub Actions生成
One workflow per concern — each file has its own triggers, permissions, concurrency:
| File | Name | Jobs | When to create |
|---|---|---|---|
| Lint | code-style, static-analysis, rector | Linters or SA detected |
| Tests | tests (+ service containers) | Always |
| Build | build | |
| Security | dependency-audit, dependency-review | |
Why one file per concern:
- Each check is a separate status check in PR — instantly see what failed
- Independent triggers — security on schedule, tests on push/PR, build only after tests
- Independent permissions — security may need
security-events: write - Can disable/re-run one workflow without touching others
- Branch protection rules can require specific workflows (e.g. require but not
tests)security
When to keep single file: Only for very small projects with just lint + tests (2 jobs). As soon as there are 3+ concerns — split.
Every workflow gets the same header pattern:
yaml
name: <Name>
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: readPer-file job organization:
lint.yml| Job | Purpose | When to include |
|---|---|---|
| Formatting (CS-Fixer, Prettier, Ruff format, rustfmt) | Formatter detected |
| Linting (ESLint, Ruff check, Clippy, golangci-lint) | Linter detected |
| Type checking / SA (PHPStan, Psalm, mypy, tsc) | SA tools detected |
| Rector dry-run (PHP only) | Rector detected |
All jobs run in parallel (no ). If only one tool detected (e.g. Go with just golangci-lint) — single job in the file is fine.
needstests.yml| Job | Purpose | When to include |
|---|---|---|
| Unit/integration tests | Always |
| Tests requiring service containers | |
Matrix builds (multiple language versions) only in this file.
build.yml| Job | Purpose | Notes |
|---|---|---|
| Verify compilation/bundling | Can depend on external workflow via |
security.yml| Job | Purpose | Extra triggers |
|---|---|---|
| Vulnerability scan | |
| PR dependency diff | Only on |
Per-job rules:
- Each job gets its own setup (checkout, language setup, cache, dependency install)
- Use language-specific setup actions with built-in cache:
- PHP: with
shivammathur/setup-php@v2parametertools: - Node.js: with
actions/setup-node@v4parametercache: - Python: (if uv) or
astral-sh/setup-uv@v5(if pip)actions/setup-python@v5 - Go: (auto-caches)
actions/setup-go@v5 - Rust: +
dtolnay/rust-toolchain@stableSwatinem/rust-cache@v2 - Java: with
actions/setup-java@v4parametercache:
- PHP:
- Use in matrix builds
fail-fast: false - Upload coverage as artifact when
WANT_COVERAGE
Matrix builds (when ):
WANT_MATRIXOnly the job uses a matrix. Lint/SA jobs run on the latest version only.
testsyaml
tests:
name: Tests (${{ matrix.<language>-version }})
strategy:
fail-fast: false
matrix:
<language>-version: <language_versions from PROJECT_PROFILE>Combining linter jobs:
If the project has both a formatter AND a linter from the same ecosystem, combine them into one job:
- PHP: check + other lint ->
php-cs-fixerjobcode-style - Node.js: +
eslint->prettierjob. Biome replaces BOTH ESLint and Prettier — if Biome is detected, use onlylintin a singlenpx biome check .joblint - Python: +
ruff check->ruff format --checkjob (Ruff handles both)lint - Rust: +
cargo fmt-> can be separate (fmt is fast, clippy needs compilation)cargo clippy
Do NOT combine lint/SA with tests — they should fail independently with clear feedback.
Use the templates in and as a base for generating workflow files. Follow the header pattern (name, on, concurrency, permissions) and per-file job organization described above.
templates/github/templates/gitlab/按关注点拆分工作流 — 每个文件有独立的触发器、权限、并发设置:
| 文件 | 名称 | 任务 | 创建条件 |
|---|---|---|---|
| 代码检查 | code-style, static-analysis, rector | 检测到代码检查器或静态分析工具 |
| 测试 | tests(+服务容器) | 始终创建 |
| 构建 | build | |
| 安全 | dependency-audit, dependency-review | |
按关注点拆分文件的原因:
- 每个检查在PR中是独立的状态检查 — 可立即查看哪项失败
- 独立触发器 — 安全扫描按计划执行,测试在推送/PR时执行,构建仅在测试通过后执行
- 独立权限 — 安全任务可能需要权限
security-events: write - 可单独禁用/重新运行一个工作流,无需修改其他工作流
- 分支保护规则可要求特定工作流(例如要求但不要求
tests)security
何时使用单个文件: 仅适用于极小项目(仅代码检查 + 测试两个任务)。一旦有3个及以上关注点 — 拆分文件。
所有工作流使用相同的头部模式:
yaml
name: <名称>
on:
push:
branches: [main]
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read按文件组织任务:
lint.yml| 任务 | 用途 | 包含条件 |
|---|---|---|
| 代码格式化(CS-Fixer、Prettier、Ruff format、rustfmt) | 检测到格式化工具 |
| 代码检查(ESLint、Ruff check、Clippy、golangci-lint) | 检测到代码检查器 |
| 类型检查/静态分析(PHPStan、Psalm、mypy、tsc) | 检测到静态分析工具 |
| Rector预运行(仅PHP) | 检测到Rector |
所有任务并行运行(无依赖)。若仅检测到一个工具(例如仅使用golangci-lint的Go项目) — 文件中单个任务即可。
needstests.yml| 任务 | 用途 | 包含条件 |
|---|---|---|
| 单元/集成测试 | 始终包含 |
| 需要服务容器的测试 | 检测到 |
仅在此文件中使用矩阵构建(多语言版本)。
build.yml| 任务 | 用途 | 说明 |
|---|---|---|
| 验证编译/打包 | 可通过 |
security.yml| 任务 | 用途 | 额外触发器 |
|---|---|---|
| 漏洞扫描 | |
| PR依赖项差异检查 | 仅在 |
任务规则:
- 每个任务有独立的初始化步骤(代码检出、语言环境设置、缓存、依赖安装)
- 使用内置缓存的语言特定初始化Action:
- PHP: ,带
shivammathur/setup-php@v2参数tools: - Node.js: ,带
actions/setup-node@v4参数cache: - Python: 若使用uv则用,若使用pip则用
astral-sh/setup-uv@v5actions/setup-python@v5 - Go: (自动缓存)
actions/setup-go@v5 - Rust: +
dtolnay/rust-toolchain@stableSwatinem/rust-cache@v2 - Java: ,带
actions/setup-java@v4参数cache:
- PHP:
- 矩阵构建中使用
fail-fast: false - 当为真时,上传覆盖率作为工件
WANT_COVERAGE
矩阵构建(当为真时):
WANT_MATRIX仅任务使用矩阵。代码检查/静态分析任务仅在最新版本上运行。
testsyaml
tests:
name: Tests (${{ matrix.<language>-version }})
strategy:
fail-fast: false
matrix:
<language>-version: <来自PROJECT_PROFILE的language_versions>合并代码检查任务:
若项目同时使用同一生态系统的格式化工具和代码检查器,将它们合并为一个任务:
- PHP: 检查 + 其他代码检查 ->
php-cs-fixer任务code-style - Node.js: +
eslint->prettier任务。Biome可替代ESLint和Prettier — 若检测到Biome,仅在单个lint任务中使用lintnpx biome check . - Python: +
ruff check->ruff format --check任务(Ruff同时处理两者)lint - Rust: +
cargo fmt-> 可分开(fmt速度快,clippy需要编译)cargo clippy
请勿合并代码检查/静态分析与测试任务 — 它们应独立失败并提供清晰反馈。
使用和中的模板作为生成工作流文件的基础。遵循上述头部模式(名称、触发器、并发、权限)和按文件组织任务的规则。
templates/github/templates/gitlab/4.2 GitLab CI Generation
4.2 GitLab CI生成
Output file:
.gitlab-ci.ymlFor GitLab-specific pipeline structure, cache strategy, report format integration, and language-specific patterns → read
references/GITLAB-PATTERNS.mdPipeline stages: install → lint → test → build → security
输出文件:
.gitlab-ci.ymlGitLab特定的流水线结构、缓存策略、报告格式集成和语言特定模式 → 阅读
references/GITLAB-PATTERNS.md流水线阶段:install → lint → test → build → security
4.3 Service Containers
4.3 服务容器
If is not empty, add service containers to the test job.
For GitHub Actions and GitLab CI service container syntax → read
services_neededreferences/SERVICE-CONTAINERS.md若不为空,在测试任务中添加服务容器。GitHub Actions和GitLab CI的服务容器语法 → 阅读
services_neededreferences/SERVICE-CONTAINERS.mdQuality Checks (Before Writing)
质量检查(写入前)
Verify generated pipeline before writing:
Correctness:
- Every job has checkout/setup/install steps
- Cache is configured for the correct lock file
- All commands match tools actually present in the project
- Matrix versions match the project's version constraints
- Service containers have health checks
Best practices:
- group set (GitHub Actions)
concurrency - set (GitHub Actions)
permissions: contents: read - set (GitLab CI)
interruptible: true - defined (GitLab CI)
workflow.rules - Jobs are parallel where possible (no unnecessary )
needs - on matrix builds
fail-fast: false
No over-engineering:
- No jobs for tools not present in the project
- No matrix builds if the project only targets one version
- No security scanning unless requested or tools are installed
- No build job if the project has no build step
写入前验证生成的流水线:
正确性:
- 每个任务都有检出/初始化/安装步骤
- 缓存针对正确的锁定文件配置
- 所有命令与项目中实际存在的工具匹配
- 矩阵版本与项目的版本约束匹配
- 服务容器包含健康检查
最佳实践:
- 设置了组(GitHub Actions)
concurrency - 设置了(GitHub Actions)
permissions: contents: read - 设置了(GitLab CI)
interruptible: true - 定义了(GitLab CI)
workflow.rules - 任务尽可能并行执行(无不必要的依赖)
needs - 矩阵构建中设置了
fail-fast: false
避免过度设计:
- 不为项目中不存在的工具创建任务
- 若项目仅针对一个版本,不使用矩阵构建
- 除非用户请求或已安装工具,否则不添加安全扫描
- 若项目无构建步骤,不创建构建任务
Step 5: Enhance / Audit Existing Pipeline
步骤5:增强/审核现有流水线
When or , analyze against the project profile and best practices.
MODE = "enhance"MODE = "audit"EXISTING_CONTENT当或时,对照项目配置文件和最佳实践分析。
MODE = "enhance"MODE = "audit"EXISTING_CONTENT5.1 Gap Analysis
5.1 差距分析
Compare existing pipeline against :
PROJECT_PROFILEMissing jobs:
- Linter installed but no lint job in CI?
- SA tool installed but no SA job?
- Tests exist but no test job?
- Security tools installed but no security job?
Configuration issues:
- No caching configured?
- No concurrency group (GitHub Actions)?
- Using deprecated actions (e.g., instead of
actions-rs)?dtolnay/rust-toolchain - Hardcoded language versions instead of variable/matrix?
- Missing on matrix?
fail-fast: false - Using on all GitLab jobs instead of
policy: pull-pushon non-install jobs?pull
Missing features:
- No coverage reporting when coverage tools are available?
- No JUnit/codequality report integration (GitLab)?
- No path filtering for monorepos?
- No trigger (GitHub Actions)?
workflow_dispatch
将现有流水线与对比:
PROJECT_PROFILE缺失任务:
- 已安装代码检查器但CI中无代码检查任务?
- 已安装静态分析工具但CI中无静态分析任务?
- 存在测试但CI中无测试任务?
- 已安装安全工具但CI中无安全任务?
配置问题:
- 未配置缓存?
- 无并发组(GitHub Actions)?
- 使用已弃用的Action(例如用而非
actions-rs)?dtolnay/rust-toolchain - 硬编码语言版本而非使用变量/矩阵?
- 矩阵构建中缺失?
fail-fast: false - GitLab所有任务使用而非非安装任务使用
policy: pull-push?pull
缺失功能:
- 有覆盖率工具但无覆盖率报告?
- 无JUnit/codequality报告集成(GitLab)?
- 无单体仓库的路径过滤?
- 无触发器(GitHub Actions)?
workflow_dispatch
5.2 Audit Report & Fix
5.2 审核报告与修复
For audit report format, fix flow options, and display templates → read
references/AUDIT-REPORT.mdPresent results as tables with ✅/❌/⚠️ per check. Categorize recommendations by severity (CRITICAL, HIGH, MEDIUM, LOW). Ask user to choose: fix all, fix critical only, or show details first.
If fixing: preserve existing structure, job names, and ordering conventions.
审核报告格式、修复流程选项和展示模板 → 阅读
references/AUDIT-REPORT.md以表格形式展示结果,每项检查标记✅/❌/⚠️。按严重性(CRITICAL、HIGH、MEDIUM、LOW)分类建议。询问用户选择:修复全部、仅修复严重问题,或先查看详情。
修复时: 保留现有结构、任务名称和排序约定。
Step 6: Write Files
步骤6:写入文件
6.1 Generate Mode — Write Pipeline
6.1 生成模式 — 写入流水线
GitHub Actions:
Bash: mkdir -p .github/workflows
Write .github/workflows/lint.yml # If linters/SA detected
Write .github/workflows/tests.yml # Always
Write .github/workflows/build.yml # If has_build_step
Write .github/workflows/security.yml # If WANT_SECURITYOnly create files for detected concerns. If only lint + tests — two files. If the project is trivially small (single lint + single test job) — a single is acceptable.
ci.ymlGitLab CI:
Write .gitlab-ci.ymlGitLab CI uses a single — stages and DAG () handle separation.
.gitlab-ci.ymlneeds:GitHub Actions:
Bash: mkdir -p .github/workflows
Write .github/workflows/lint.yml # 若检测到代码检查器/静态分析工具
Write .github/workflows/tests.yml # 始终写入
Write .github/workflows/build.yml # 若has_build_step为真
Write .github/workflows/security.yml # 若WANT_SECURITY为真仅为检测到的关注点创建文件。若仅需代码检查 + 测试 — 创建两个文件。若项目极小(单个代码检查 + 单个测试任务) — 可使用单个文件。
ci.ymlGitLab CI:
Write .gitlab-ci.ymlGitLab CI使用单个文件 — 通过阶段和DAG()实现任务分离。
.gitlab-ci.ymlneeds:6.2 Enhance / Audit Mode — Update Existing
6.2 增强/审核模式 — 更新现有文件
Edit existing files using the tool. Preserve the original structure and only add/modify what's needed.
Edit使用工具编辑现有文件。保留原始结构,仅添加/修改必要内容。
EditStep 7: Summary & Follow-Up
步骤7:总结与后续建议
7.1 Display Summary
7.1 展示总结
Display summary using format from (Summary Display Template section). Show platform, files created, features, and quick start commands.
references/AUDIT-REPORT.md使用中的格式(总结展示模板部分)展示总结。显示平台、创建的文件、功能和快速开始命令。
references/AUDIT-REPORT.md7.2 Suggest Follow-Up Skills
7.2 建议后续技能
Suggest: for CI targets in Makefile/Taskfile, for containerization.
/aif-build-automation/aif-dockerize建议:用于Makefile/Taskfile中的CI目标,用于容器化。
/aif-build-automation/aif-dockerizeArtifact Ownership and Config Policy
工件所有权与配置策略
- Primary ownership: CI pipeline artifacts such as and
.github/workflows/*..gitlab-ci.yml - Allowed companion updates: none by default outside CI files.
- Config policy: config-agnostic by design. This skill relies on repository detection and explicit user choices, not .
config.yaml
- 主要所有权:CI流水线工件,如和
.github/workflows/*。.gitlab-ci.yml - 允许的伴随更新:默认情况下CI文件外无其他更新。
- 配置策略:设计为与配置无关。本技能依赖仓库检测和用户明确选择,而非。
config.yaml