一键导入
code-env-setup
Environment verification, dependency installation, baseline test verification
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Environment verification, dependency installation, baseline test verification
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Test failure diagnosis, source code fixes, and regression detection
Contract-first single-task implementation dispatched by Coder Coordinator
Integration test writing for component boundaries and external dependencies
Unit test writing and execution with coverage threshold enforcement
API reference documentation skill. Produces and updates API endpoint documentation from contract files in .sdd/docs/api-reference.md.
Architecture documentation skill. Produces and updates architecture overview, component diagrams, technology stack, design decisions, and directory structure in .sdd/docs/architecture.md.
| name | code-env-setup |
| description | Environment verification, dependency installation, baseline test verification |
| argument-hint | Invoked by Coder Coordinator - do not call directly |
Phase: 1 (Environment Setup) Common contract:
.github/skills/CODER-SKILL-CONTRACT.mdSpec refs: FR-020, FR-021, FR-022
This skill is dispatched by the Coder Coordinator during Phase 1. It verifies or creates the development environment, installs project dependencies, configures coverage tooling, runs baseline tests, and documents environment state.
| # | Input | Description |
|---|---|---|
| 1 | skill_path | Path to this SKILL.md file |
| 2 | wp_path | Path to the WP file being implemented |
| 3 | contracts_dir | Path to contract files for this WP (.sdd/plans/contracts/<WP-slug>/) |
| 4 | spec_path | Path to the source spec file |
| 5 | patterns | Active code-domain patterns to avoid (from code-patterns.md) |
| 6 | target_language | Programming language (e.g., TypeScript, Python) |
| 7 | target_framework | Framework (e.g., Express, FastAPI, React) |
| 8 | task_list | Tasks with acceptance criteria and spec refs |
Report to the coordinator with these fields:
| Field | Type | Constraints | Description |
|---|---|---|---|
status | enum | success or failure | Skill outcome |
files_modified | list(string) | file paths | Files created or changed |
tasks_completed | list(string) | T-XX format | Tasks finished |
test_results | object | pass_count, fail_count, coverage_pct | Baseline test run summary |
issues | list(string) | free text | Problems encountered |
failure_reason | string | nullable | Why the skill failed (if status is failure) |
Check for an existing development environment by scanning for these indicators in priority order:
.venv/ or venv/ directorypyproject.toml (Poetry, PDM, Hatch, or PEP 621)requirements.txt or requirements-dev.txtsetup.py or setup.cfgPipfile (Pipenv)conda.yaml or environment.yml (Conda)node_modules/ directorypackage.jsonpackage-lock.json, yarn.lock, or pnpm-lock.yaml (determines package manager)go.modgo.sumCargo.tomlCargo.lockMakefile, Dockerfile, docker-compose.yml.tool-versions (asdf) or .mise.toml (mise)Decision logic:
target_language from the input to determine the primary environmentIf an environment directory exists (e.g., node_modules/, .venv/) but a basic health check fails, the environment is considered broken. Health checks:
node -e "require('./package.json')" and npx --version. If either fails, the environment is broken.<venv>/bin/python --version (or <venv>\Scripts\python --version on Windows) and verify it exits 0. If it fails, the environment is broken.go env GOPATH and verify it exits 0.cargo --version and verify it exits 0.Recovery procedure:
rm -rf node_modules or rm -rf .venv).Do NOT attempt to repair a broken environment -- always delete and recreate.
Create a new development environment based on the detected or specified language:
python -m venv .venv
.venv\Scripts\activatesource .venv/bin/activatepython is not available, try python3Version check: Verify the Python version meets the project's minimum requirement. Check pyproject.toml [project] requires-python, setup.cfg python_requires, or Pipfile [requires] python_version.
status: failure
failure_reason: "Python version mismatch: project requires >=3.11 but installed version is 3.8.10"
Do NOT proceed with installation. The coordinator will escalate to the human.Determine the package manager from lockfile presence:
package-lock.json -> npm installyarn.lock -> yarn installpnpm-lock.yaml -> pnpm installnpm install (default)Version check: Check .nvmrc, .node-version, or package.json engines.node for version requirements. If the installed Node version does not meet the requirement, report the incompatibility and halt.
go mod download
Version check: Check go.mod go directive for version requirements.
cargo fetch
Version check: Check rust-toolchain.toml or rust-toolchain for version requirements.
If the target_language is not one of the above:
Makefile with a setup, install, or init targetREADME.md with setup instructionsInstall project dependencies from the dependency manifest. Use #tool:execute/executionSubagent for dependency installation commands -- it runs multi-step installs and returns only relevant output (errors, version conflicts) instead of full verbose logs.
| Manifest | Command |
|---|---|
requirements.txt | pip install -r requirements.txt |
requirements-dev.txt | pip install -r requirements-dev.txt |
pyproject.toml (with [project]) | pip install -e ".[dev]" or pip install -e . |
pyproject.toml (Poetry) | poetry install |
Pipfile | pipenv install --dev |
Already handled in Step 2 (package manager install). If node_modules/ existed but package.json has changed, re-run the install command.
go mod download
go build ./...
cargo build
Error handling: If dependency installation fails:
failure_reasonInstall the coverage tooling appropriate for the target language and configure minimum thresholds.
Before configuring coverage tooling, read the minimum thresholds from the WP file's YAML frontmatter:
coverage_code from WP frontmatter. If the field is absent, use the default: 80.coverage_branch from WP frontmatter. If the field is absent, use the default: 90.coverage_branch).Use the resolved coverage_code and coverage_branch values (from frontmatter or defaults) in all configuration examples below, replacing the placeholder <coverage_code> and <coverage_branch>.
Install:
pip install pytest-cov
Configure in pytest.ini, pyproject.toml, or setup.cfg using the resolved thresholds:
[tool:pytest]
addopts = --cov --cov-branch --cov-fail-under=<coverage_code>
[coverage:report]
fail_under = <coverage_code>
[coverage:run]
branch = True
If using pyproject.toml:
[tool.pytest.ini_options]
addopts = "--cov --cov-branch --cov-fail-under=<coverage_code>"
[tool.coverage.report]
fail_under = <coverage_code>
[tool.coverage.run]
branch = true
Thresholds: Use the coverage_code and coverage_branch values read from WP frontmatter (defaults: 80% code, 90% branch per FR-037).
For Jest projects, add to jest.config.js or package.json using the resolved thresholds:
{
"jest": {
"collectCoverage": true,
"coverageThreshold": {
"global": {
"statements": <coverage_code>,
"branches": <coverage_branch>,
"functions": <coverage_code>,
"lines": <coverage_code>
}
}
}
}
For nyc (Mocha, etc.):
Create or update .nycrc:
{
"check-coverage": true,
"statements": <coverage_code>,
"branches": <coverage_branch>,
"functions": <coverage_code>,
"lines": <coverage_code>
}
Go has built-in coverage. No additional tool installation needed. Configure coverage thresholds in the test runner script or CI configuration:
go test -coverprofile=coverage.out -covermode=atomic ./...
Install:
cargo install cargo-tarpaulin
Note: Only install or configure coverage tooling if it is not already present. Do not overwrite existing coverage configuration unless the thresholds are below the WP-specified minimums.
Run the project's existing test suite to verify a green baseline:
| Language | Command |
|---|---|
| Python | pytest or python -m pytest |
| Node.js | npm test or yarn test |
| Go | go test ./... |
| Rust | cargo test |
Decision logic:
If the project has an entry point (e.g., main.py, server.js, main.go):
If there is no clear entry point (library, framework plugin, etc.): skip this step and document "No application entry point -- launch verification skipped."
Append an entry to the WP Activity Log documenting:
Format:
- <timestamp> - code-env-setup - Environment: <language> <version>, <framework> <version>. Venv: <type>. Dependencies: <count> installed. Baseline: <test_summary>. Coverage: <tool> configured (<coverage_code>% code / <coverage_branch>% branch).
If the environment cannot be established at any step, follow this 3-part failure protocol:
Record in the skill output:
Set the output contract fields:
status: failure
failure_reason: "<step> failed: <exact error message>"
issues: ["<detailed description of the failure>"]
The coordinator SHALL escalate to the human upon receiving a failure status from this skill. The skill does NOT attempt to recover from environment failures -- recovery requires human judgment.
Common failure scenarios:
| Scenario | Expected Behavior |
|---|---|
| Missing runtime (e.g., Python not installed) | Report: "Python runtime not found. Install Python >= <required_version>." |
| Version mismatch (e.g., Python 3.8 vs required 3.11) | Report: "Python version mismatch: requires >= 3.11, found 3.8.10" |
| Dependency conflict | Report exact pip/npm error output |
| Network error during install | Report: "Network error during dependency installation: " |
| Missing system library | Report: "Missing system dependency: . Install via <package_manager>." |
| Insufficient permissions | Report: "Permission denied: . Check file system permissions." |
.sdd/plans/contracts/. Contracts are the Planner's output.patterns input. These are mistakes from prior reviews.