---
name: pipeline-coding-standard
description: 编写或修改pipeline代码。仅在用户明确要求pipeline时使用；只管代码组织，不管最终展示格式。
title: pipeline-coding-standard
canonical_url: https://skilld.dev/gh/victory-hugo/s2-agent-skill/pipeline-coding-standard
last_updated: 2026-10-08T20:10:09.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [assets/project-template/conf/1-data_preprocessing.yaml](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/assets/project-template/conf/1-data_preprocessing.yaml), [assets/project-template/pipe/1-data_preprocessing.sh](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/assets/project-template/pipe/1-data_preprocessing.sh), [assets/project-template/python/1-1-data_preprocessing.py](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/assets/project-template/python/1-1-data_preprocessing.py), [assets/project-template/script/check_env.sh](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/assets/project-template/script/check_env.sh), [assets/project-template/script/load_config.sh](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/assets/project-template/script/load_config.sh), [assets/project-template/src/.keep](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/assets/project-template/src/.keep), [scripts/init_pipeline_layout.sh](https://skilld.dev/api/skills-raw/victory-hugo/s2-agent-skill/pipeline-coding-standard/scripts/init_pipeline_layout.sh).
>
> If the user asked to install this Skill, run `npx skilld install victory-hugo/s2-agent-skill/pipeline-coding-standard`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/pipeline-coding-standard`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/victory-hugo/s2-agent-skill/pipeline-coding-standard) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/pipeline-coding-standard`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/pipeline-coding-standard --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/pipeline-coding-standard --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Pipeline Coding Standard

## Scope

本 Skill 只规定 pipeline 的**代码组织**：目录、步骤、配置、命名。

## Layout

所有目录直接建在项目根下，不得嵌套：

```text
conf/      # 每个步骤一个 YAML
pipe/      # 每个步骤一个总控 .sh
script/    # shell 辅助工具
python/  R/  src/    # 各语言业务模块
output/{result,figure}/<N>-<name>/
temp/<N>-<name>/     # 中间文件
data/  input/  log/
```

## Steps

1. 步骤编号和名称必须一致：`pipe/1-xxx.sh`、`conf/1-xxx.yaml`、`output/*/1-xxx/`、`temp/1-xxx/`。
2. 一个 pipe 只读取同名 conf，禁止使用全局统一配置文件。
3. 任务较大时必须拆分为多个编号步骤。
4. 业务代码命名为 `<N>-<M>-<name>.<ext>`，`script/` 中的辅助工具可使用描述性名称。

## Config

1. pipe 通过 `script/load_config.sh` 读取 conf，再以命名 CLI 参数传给模块。
2. 模块禁止自行读取 YAML，也禁止硬编码路径、软件路径、环境路径和线程数。
3. conf 至少包含 `paths`（输入、输出、temp）、`tools`（软件和环境路径）和 `runtime`（`jobs`、`overwrite`）。

## Output

1. `output/result/` 默认输出 TSV。这是**机器可读的完整精度数据**，不做四位有效数字取整。
2. `output/figure/` 中每张图配一个同名 TSV，包含出图所用的全部数据，同样保留完整精度。只需要输出pdf格式的图，png、svg、jpg等格式不需要。
3. 所有中间文件放在项目根下的 `temp/<N>-<name>/`，禁止使用项目外目录。

## Debugging

调试、试运行、预分析和临时脚本，一律在项目根下的 `temp/<N>-<name>/` 中进行。原因：`/tmp`、`$HOME` 和 Agent 自带的 scratchpad 目录在重启后可能丢失，会导致调试过程和中间结果全部消失。禁止在 `/tmp`、`$HOME`、`$HOME/tmp`、`$HOME/temp`、Agent scratchpad 等项目外目录中调试或存放临时文件。调试结论确认后，再把正式代码移入 `pipe/`、`python/`、`R/` 等目录，`temp/` 中的内容不作为最终交付物。

## Code

一个文件只用一种语言，shell 中不得嵌入 Python 或 R 片段。

## Workflow

- **新建项目**：运行 `bash scripts/init_pipeline_layout.sh <target_dir>` 复制模板，再补充各步骤。
- **重构旧脚本**：配置迁入 conf，流程控制迁入 pipe，业务逻辑迁入对应语言目录。
