mcpField
S
shadow-testing

shadow-testing

github.com/rysweet测试与质量76121 次安装21 周前更新
代码仓库

关于 shadow-testing

shadow-testing 提供技能和命令行工具,可在隔离的 Docker 或 Podman 容器中测试本地未提交的仓库改动。它支持单仓库和多仓库验证,避免影响主机或推送代码。

主要功能

  1. 01基于容器的隔离测试环境
  2. 02快照包含未提交改动
  3. 03通过 Gitea 重写本地 Git URL
  4. 04各环境独立的软件包缓存
  5. 05命令行及 Amplifier 集成

适用场景

  1. 01推送前验证改动
  2. 02用本地库改动测试依赖项目
  3. 03联合验证多个仓库的改动
  4. 04在干净环境运行 CI 脚本

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/rysweet/amplihack --skill shadow-testing

安装后在 Claude Code 中输入/shadow-testing确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

README.md
docker-compose/
README.md
ci-shadow.yml
multi-repo.yml
single-repo.yml
examples/
multi-repo-coordination.md
nodejs-package-test.md
python-library-test.md
scripts/
create-bundle.sh
setup-shadow.sh
test-shadow.sh

详细介绍

Shadow Testing 技能

用途 [LEVEL 1]

Shadow Testing 会创建隔离的容器环境,让你能够测试本地尚未提交的更改,而不会影响主机系统或推送到远程仓库。

核心原则:在干净、隔离且与 CI 环境一致的环境中,准确测试你机器上的内容(包括尚未提交的更改)。

何时使用此技能 [LEVEL 1]

最适合的场景
  • 推送前验证:在提交或推送前测试更改
  • 多仓库协作:验证多个仓库中的更改能否协同工作
  • 干净状态测试:“在一台新机器上能正常运行吗?”
  • 库开发:使用依赖项目测试库的更改
  • CI 环境一致性:推送前查看 CI 将会看到什么
  • 破坏性测试:不会让修改系统状态的测试影响主机
在以下情况下使用此技能
  • 对其他项目所依赖的库进行破坏性更改
  • 协调多个仓库之间的更改
  • 不确定更改能否在 CI 中正常运行
  • 需要使用特定版本的依赖进行测试
  • 想要验证安装或设置流程是否正常
  • 测试需要干净环境状态的更改
在以下情况下不要使用此技能
  • 对已提交的代码运行单元测试(使用本地测试运行器)
  • 需要使用实时代码更改进行调试(shadow 使用的是快照)
  • 测试生产环境部署(使用预发布环境)
  • 有完善测试覆盖的简单单文件更改

核心概念 [LEVEL 1]

Shadow 环境架构

Shadow 环境是一个 Docker/Podman 容器,包含:

  1. Git Bundle 快照 - 精确的工作树状态(包括尚未提交的更改)
  2. 内置 Gitea 服务 - 容器内 localhost:3000 上的本地 git 服务
  3. 选择性 URL 重写 - Git insteadOf 规则将特定仓库重定向到本地 Gitea
  4. 包管理器隔离 - UV、pip、npm、cargo、go 缓存按 shadow 隔离
  5. API 密钥透传 - 常见 API 密钥会自动转发到容器
┌─────────────────────────────────────────────────────────┐
│  Shadow Container                                       │
│  ┌───────────────────────────────────────────────────┐  │
│  │  Gitea Server (localhost:3000)                    │  │
│  │  - myorg/my-library (your snapshot)               │  │
│  └───────────────────────────────────────────────────┘  │
│                                                         │
│  Git URL Rewriting:                                     │
│  github.com/myorg/my-library → Gitea (local)           │
│  github.com/myorg/other-repo → Real GitHub             │
│                                                         │
│  /workspace (pre-cloned local sources)                 │
└─────────────────────────────────────────────────────────┘
Git URL 重写的工作原理

使用 ~/repos/my-lib:myorg/my-lib 创建 shadow 时:

  1. 工作目录会按原样捕获(包括尚未提交的更改)
  2. 快照会与完整的 git 历史一起打包
  3. 容器启动并运行 Gitea 服务
  4. 快照会以 myorg/my-lib 的名称推送到 Gitea
  5. Git 配置会添加 insteadOf 规则:
    [url "http://shadow:shadow@localhost:3000/myorg/my-lib.git"]
        insteadOf = https://github.com/myorg/my-lib.git
    
  6. 任何 git clone https://github.com/myorg/my-lib → 都会使用你的本地快照
  7. 所有其他 GitHub URL → 从真实的 GitHub 获取

结果:只有你指定的仓库位于本地;其他所有内容都使用生产源。

快速入门 [LEVEL 1]

安装

Amplifier 用户(原生集成):

# Shadow tool is built-in - no installation needed
amplifier run --bundle amplihack

其他 Agent(独立 CLI):

# Install via uvx (recommended)
uvx amplifier-shadow --version

# Or via pip
pip install amplifier-bundle-shadow

# Verify installation
amplifier-shadow --version

先决条件:

  • 已安装并运行 Docker 或 Podman
  • 已安装 Git
创建你的第一个 Shadow(CLI)
# Create shadow with your local library changes
amplifier-shadow create --local ~/repos/my-library:myorg/my-library --name test-lib

# Inside the shadow, install via git URL
# → my-library uses YOUR LOCAL snapshot
# → all other dependencies fetch from REAL GitHub
amplifier-shadow exec test-lib "uv pip install git+https://github.com/myorg/my-library"

# Run tests
amplifier-shadow exec test-lib "cd /workspace && pytest"

# See what changed
amplifier-shadow diff test-lib

# Clean up when done
amplifier-shadow destroy test-lib
创建你的第一个 Shadow(Amplifier 工具)
# Create shadow with local changes
shadow.create(local_sources=["~/repos/my-library:myorg/my-library"])

# Execute commands
shadow.exec(shadow_id, "uv pip install git+https://github.com/myorg/my-library")
shadow.exec(shadow_id, "pytest tests/")

# Extract results
shadow.extract(shadow_id, "/workspace/test-results", "./results")

# Cleanup
shadow.destroy(shadow_id)

按 Agent 类型划分的工具参考 [LEVEL 2]

Amplifier(原生集成)

最佳体验 - shadow 是一等工具,并可自动设置:

# All operations via shadow tool
result = shadow.create(
    local_sources=["~/repos/lib:org/lib"],
    verify=True  # Automatic smoke test
)

# Integrated error handling and observability
if result.ready:
    shadow.exec(result.shadow_id, "pytest")

功能:

  • 自动透传 API 密钥
  • 内置冒烟测试和运行状况检查
  • 与其他 Amplifier 工具集成
  • 感知会话的清理
Claude Code 独立版

直接通过 bash 工具使用 CLI:

# All operations via amplifier-shadow CLI
uvx amplifier-shadow create --local ~/repos/my-lib:org/my-lib --name test

uvx amplifier-shadow exec test "pip install -e /workspace/org/my-lib"
uvx amplifier-shadow exec test "pytest"

uvx amplifier-shadow destroy test
GitHub Copilot

与 Claude Code 相同的 CLI 接口:

# Install once
pip install amplifier-bundle-shadow

# Use in workflow
amplifier-shadow create --local ~/repos/lib:org/lib
amplifier-shadow exec shadow-xxx "npm install && npm test"
手动/DIY(任何 Agent)

使用提供的 shell 脚本和 Docker Compose 示例(见第 3 级)。

常见模式 [LEVEL 2]

模式:发布前测试库的更改
# Test your library with its dependents
amplifier-shadow create --local ~/repos/my-library:myorg/my-library --name lib-test

# Clone dependent project and install
amplifier-shadow exec lib-test "
  cd /workspace &&
  git clone https://github.com/myorg/dependent-app &&
  cd dependent-app &&
  uv venv && . .venv/bin/activate &&
  uv pip install git+https://github.com/myorg/my-library &&
  pytest
"
模式:多仓库更改
# Testing changes across multiple repos
amplifier-shadow create \
    --local ~/repos/core-lib:myorg/core-lib \
    --local ~/repos/cli-tool:myorg/cli-tool \
    --name multi-test

# Both local sources will be used
amplifier-shadow exec multi-test "uv pip install git+https://github.com/myorg/cli-tool"
模式:根据失败结果迭代
# 1. Create shadow and run tests
amplifier-shadow create --local ~/repos/lib:org/lib --name test
amplifier-shadow exec test "pytest" # Fails

# 2. Fix code locally on host

# 3. Destroy and recreate (picks up your local changes)
amplifier-shadow destroy test
amplifier-shadow create --local ~/repos/lib:org/lib --name test
amplifier-shadow exec test "pytest" # Passes

# 4. Commit with confidence!
git commit -m "Fix issue"
模式:推送前进行 CI 验证
# Run your CI script in shadow before pushing
amplifier-shadow create --local ~/repos/project:org/project --name ci-check

amplifier-shadow exec ci-check "
  cd /workspace/org/project &&
  ./scripts/ci.sh
"

# If CI script passes, your push will likely succeed

验证最佳实践 [LEVEL 2]

始终验证是否使用了本地源

创建 shadow 后,确认实际使用的是你的本地代码:

# Step 1: Check snapshot commits (from create output)
amplifier-shadow create --local ~/repos/lib:org/lib
# Output shows: snapshot_commits: {"org/lib": "abc1234..."}

# Step 2: Compare with install output
amplifier-shadow exec shadow-xxx "uv pip install git+https://github.com/org/lib"
# Look for: lib @ git+...@abc1234

# If commits match, your local code is being used!
预克隆的仓库位置

本地源会自动克隆到 /workspace/{org}/{repo}:

# Your local source microsoft/my-library is available at:
/workspace/microsoft/my-library

# Use for editable installs (Python)
amplifier-shadow exec shadow-xxx "pip install -e /workspace/microsoft/my-library"

# Or for Node.js
amplifier-shadow exec shadow-xxx "cd /workspace/microsoft/my-package && npm install"

请始终先检查此位置——仓库已经在这里。

环境变量验证
# Don't assume - verify API keys are present!
amplifier-shadow exec shadow-xxx "env | grep API_KEY"

# Check all passed variables
amplifier-shadow status shadow-xxx
# Shows: env_vars_passed: ["ANTHROPIC_API_KEY", ...]

故障排除 [LEVEL 2]

常见问题

“UV tool install” 使用缓存而非本地源:

问题:UV 可能会绕过针对缓存包的 Git URL 重写。

解决方案:

# Option 1: Install from pre-cloned workspace (recommended)
amplifier-shadow exec xxx "pip install -e /workspace/org/lib"

# Option 2: Clear UV cache first
amplifier-shadow exec xxx "rm -rf /tmp/uv-cache && uv tool install git+https://github.com/org/lib"

“PEP 668: Externally-Managed Environment”:

解决方案:始终在 shadow 中使用虚拟环境:

amplifier-shadow exec xxx "
  cd /workspace &&
  uv venv &&
  . .venv/bin/activate &&
  uv pip install ...
"

“Container image not found”:

解决方案:在本地构建镜像:

amplifier-shadow build

“/workspace permission denied”:

解决方案:使用 $HOME 或 /tmp 作为替代路径:

amplifier-shadow exec xxx "cd $HOME && git clone ..."

Level 3:高级主题 [LEVEL 3]

自定义 Docker 镜像

使用其他工具构建自己的 shadow 镜像:

FROM ghcr.io/microsoft/amplifier-shadow:latest

# Add your tools
RUN apt-get update && apt-get install -y \
    postgresql-client \
    redis-tools

# Add custom scripts
COPY my-test-script.sh /usr/local/bin/

构建并使用:

docker build -t my-shadow:latest .
amplifier-shadow create --image my-shadow:latest --local ~/repos/lib:org/lib
Shell 脚本(DIY Shadow 设置)

对于无法访问 Amplifier 的 Agent,请使用以下独立脚本:

脚本 1:创建 Git Bundle(scripts/create-bundle.sh):

#!/bin/bash
# Create git bundle snapshot of working tree

REPO_PATH=$1
OUTPUT_PATH=$2

cd "$REPO_PATH"

# Fetch all refs to ensure complete history
git fetch --all --tags --quiet 2>/dev/null || true

# Check for uncommitted changes
if [[ -n $(git status --porcelain) ]]; then
    # Create temp clone and commit changes
    TEMP_DIR=$(mktemp -d)
    git clone --quiet "$REPO_PATH" "$TEMP_DIR"

    # Sync working tree (including deletions)
    rsync -a --delete --exclude='.git' "$REPO_PATH/" "$TEMP_DIR/"

    cd "$TEMP_DIR"
    git add -A
    git commit --allow-empty -m "Shadow snapshot" --author="Shadow <shadow@localhost>"

    # Create bundle
    git bundle create "$OUTPUT_PATH" --all

    cd /
    rm -rf "$TEMP_DIR"
else
    # Clean repo - just bundle it
    git bundle create "$OUTPUT_PATH" --all
fi

echo "Bundle created: $OUTPUT_PATH"

脚本 2:设置 Shadow 容器(scripts/setup-shadow.sh):

#!/bin/bash
# Start container with Gitea and configure git URL rewriting

CONTAINER_NAME=$1
BUNDLE_PATH=$2
ORG=$3
REPO=$4

# Start container
docker run -d \
    --name "$CONTAINER_NAME" \
    -v "$BUNDLE_PATH:/snapshots/bundle.git:ro" \
    ghcr.io/microsoft/amplifier-shadow:latest

# Wait for Gitea
echo "Waiting for Gitea to start..."
until docker exec "$CONTAINER_NAME" curl -sf http://localhost:3000/api/v1/version > /dev/null; do
    sleep 1
done

# Create org and repo in Gitea
docker exec "$CONTAINER_NAME" bash -c "
    curl -s -u shadow:shadow \
        -H 'Content-Type: application/json' \
        -d '{\"username\":\"$ORG\"}' \
        http://localhost:3000/api/v1/orgs

    curl -s -u shadow:shadow \
        -H 'Content-Type: application/json' \
        -d '{\"name\":\"$REPO\",\"private\":false}' \
        http://localhost:3000/api/v1/orgs/$ORG/repos
"

# Push bundle to Gitea
docker exec "$CONTAINER_NAME" bash -c "
    cd /tmp &&
    git init --bare repo.git &&
    cd repo.git &&
    git fetch /snapshots/bundle.git refs/heads/*:refs/heads/* &&
    git remote add origin http://shadow:shadow@localhost:3000/$ORG/$REPO.git &&
    git push origin --all --force
"

# Configure git URL rewriting
docker exec "$CONTAINER_NAME" bash -c "
    git config --global url.'http://shadow:shadow@localhost:3000/$ORG/$REPO.git'.insteadOf 'https://github.com/$ORG/$REPO.git'
"

echo "Shadow container ready: $CONTAINER_NAME"
echo "Local source: $ORG/$REPO"

用法:

# Create bundle from your repo
./scripts/create-bundle.sh ~/repos/my-lib /tmp/my-lib.bundle

# Setup shadow container
./scripts/setup-shadow.sh shadow-test /tmp/my-lib.bundle myorg my-lib

# Test
docker exec shadow-test bash -c "
    git clone https://github.com/myorg/my-lib /tmp/test &&
    cd /tmp/test &&
    git log -1 --oneline
"
Docker Compose 示例

示例 1:单个仓库(docker-compose/single-repo.yml):

version: "3.8"

services:
  shadow:
    image: ghcr.io/microsoft/amplifier-shadow:latest
    container_name: shadow-single
    volumes:
      - ./snapshots:/snapshots:ro
      - ./workspace:/workspace
    environment:
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    command: >
      bash -c "
        /usr/local/bin/gitea-init.sh &&
        tail -f /dev/null
      "

示例 2:多仓库测试(docker-compose/multi-repo.yml):

version: "3.8"

services:
  shadow-multi:
    image: ghcr.io/microsoft/amplifier-shadow:latest
    container_name: shadow-multi
    volumes:
      # Mount multiple bundles
      - ./snapshots/core-lib.bundle:/snapshots/org/core-lib.bundle:ro
      - ./snapshots/cli-tool.bundle:/snapshots/org/cli-tool.bundle:ro
      - ./workspace:/workspace
    environment:
      # Pass API keys from host
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY}
      # UV cache isolation
      - UV_CACHE_DIR=/tmp/uv-cache
    command: >
      bash -c "
        /usr/local/bin/gitea-init.sh &&
        /usr/local/bin/setup-repos.sh org/core-lib org/cli-tool &&
        tail -f /dev/null
      "

用法:

# Create bundles for your repos
git -C ~/repos/core-lib bundle create snapshots/core-lib.bundle --all
git -C ~/repos/cli-tool bundle create snapshots/cli-tool.bundle --all

# Start shadow
docker-compose -f docker-compose/multi-repo.yml up -d

# Run tests
docker-compose exec shadow-multi bash -c "
    cd /workspace &&
    git clone https://github.com/org/cli-tool &&
    cd cli-tool &&
    uv pip install -e .
    pytest
"

# Cleanup
docker-compose down

示例 3:CI 集成(docker-compose/ci-shadow.yml):

version: "3.8"

services:
  ci-shadow:
    image: ghcr.io/microsoft/amplifier-shadow:latest
    container_name: ci-shadow
    volumes:
      - ./snapshots:/snapshots:ro
      - ./test-results:/test-results
    environment:
      - CI=true
      - GITHUB_ACTIONS=true
    command: >
      bash -c "
        /usr/local/bin/gitea-init.sh &&
        /usr/local/bin/run-ci-tests.sh > /test-results/output.log 2>&1
      "

GitHub Actions 集成:

# .github/workflows/shadow-test.yml
name: Shadow Test

on: [push, pull_request]

jobs:
  shadow-test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Create git bundle
        run: git bundle create snapshot.bundle --all

      - name: Run shadow tests
        run: |
          docker run --rm \
            -v $PWD/snapshot.bundle:/snapshots/bundle.git:ro \
            ghcr.io/microsoft/amplifier-shadow:latest \
            /usr/local/bin/test-in-shadow.sh org/repo
与 Outside-In 测试集成

将 shadow 环境与 Agent 式的 Outside-In 测试结合:

# Create shadow with local changes
amplifier-shadow create --local ~/repos/lib:org/lib --name test

# Run outside-in test scenarios inside shadow
amplifier-shadow exec test "gadugi-agentic-test run test-scenario.yaml"

# Extract evidence
amplifier-shadow extract test /evidence ./test-evidence

完整的集成示例请参阅 qa-team 技能(outside-in-testing 仍是一个别名)。

最佳实践 [LEVEL 2]

1. 始终验证使用的是你的源

不要想当然——请验证 shadow 确实在使用你的本地代码:

# Check snapshot commits
amplifier-shadow status shadow-xxx | grep snapshot_commit

# Verify install resolves to that commit
amplifier-shadow exec shadow-xxx "pip install git+https://github.com/org/lib" | grep "org/lib @"
2. 使用预克隆的工作区

本地源会自动放置在 /workspace/{org}/{repo}:

# ✅ FAST: Use pre-cloned repo
amplifier-shadow exec xxx "pip install -e /workspace/org/lib"

# ❌ SLOWER: Clone again
amplifier-shadow exec xxx "git clone https://github.com/org/lib && pip install -e lib"
3. 隔离包管理器缓存

shadow 环境会自动隔离缓存,以防止使用过期的包:

  • Python UV:/tmp/uv-cache
  • Python pip:/tmp/pip-cache
  • Node npm:/tmp/npm-cache
  • Rust cargo:/tmp/cargo-home
  • Go 模块:/tmp/go-mod-cache

这些路径会自动设置,无需操作。

4. 传递所需的环境变量
# Amplifier (automatic for common API keys)
shadow.create(local_sources=["~/repos/lib:org/lib"])

# CLI (explicit)
amplifier-shadow create \
    --local ~/repos/lib:org/lib \
    --env ANTHROPIC_API_KEY=$ANTHROPIC_API_KEY \
    --env CUSTOM_VAR=value
5. 测试后清理
# Always destroy shadows when done
amplifier-shadow destroy shadow-xxx

# Or destroy all
amplifier-shadow destroy-all
6. 使用命名的 shadow,便于辨识
# ✅ GOOD: Descriptive name
amplifier-shadow create --local ~/repos/lib:org/lib --name test-breaking-change

# ❌ BAD: Auto-generated
amplifier-shadow create --local ~/repos/lib:org/lib
# Creates shadow-a3f2b8c1 (hard to remember)

集成模式 [LEVEL 3]

模式:Shadow + Outside-In 测试

将 shadow 隔离与声明式测试场景结合:

# test-scenario.yaml
scenario:
  name: "Library Integration Test"
  type: cli

  steps:
    - action: launch
      target: "/workspace/org/lib/cli.py"

    - action: verify_output
      contains: "Success"

在 shadow 中运行:

amplifier-shadow create --local ~/repos/lib:org/lib --name test
amplifier-shadow exec test "gadugi-agentic-test run test-scenario.yaml"
模式:Shadow + pytest
amplifier-shadow create --local ~/repos/lib:org/lib --name pytest-run

amplifier-shadow exec pytest-run "
  cd /workspace/org/lib &&
  uv venv && . .venv/bin/activate &&
  pip install -e '.[dev]' &&
  pytest --cov=src --cov-report=html
"

# Extract coverage report
amplifier-shadow extract pytest-run /workspace/org/lib/htmlcov ./coverage-report
模式:Shadow + npm test
amplifier-shadow create --local ~/repos/pkg:org/pkg --name npm-test

amplifier-shadow exec npm-test "
  cd /workspace/org/pkg &&
  npm install &&
  npm test
"
模式:Shadow + cargo test
amplifier-shadow create --local ~/repos/crate:org/crate --name cargo-test

amplifier-shadow exec cargo-test "
  cd /workspace/org/crate &&
  cargo build &&
  cargo test
"

理念契合 [LEVEL 2]

此技能遵循 amplihack 的核心原则:

极致简约
  • 最少抽象:Shadow = 容器 + gitea + URL 重写
  • 无框架:纯粹使用 Docker、git 和 shell 脚本
  • 只保留必要内容:仅捕获所需内容(Git Bundle,而非整个文件系统)
模块化设计(砖块与榫头)
  • 自成一体:每个 shadow 都相互独立
  • 契约清晰:输入 Git URL,输出本地源
  • 可组合:可与其他测试工具结合使用
零废话实现
  • 无存根:每个脚本都能完整运行
  • 默认配置可用:所有操作均有合理的默认值
  • 错误信息清晰:提供可执行的错误信息和故障排除指引
Outside-In 思维
  • 用户视角:测试用户会看到的内容
  • 与实现无关:不关注代码内部的工作方式
  • 行为驱动:关注结果

CLI 参考 [LEVEL 3]

命令
# Create shadow environment
amplifier-shadow create [OPTIONS]
  --local, -l TEXT    Local source mapping: /path/to/repo:org/name (repeatable)
  --name, -n TEXT     Name for environment (auto-generated if not provided)
  --image, -i TEXT    Container image (default: amplifier-shadow:local)
  --env, -e TEXT      Environment variable: KEY=VALUE or KEY to inherit (repeatable)
  --env-file FILE     File with environment variables (one per line)
  --pass-api-keys     Auto-pass common API key env vars (default: enabled)

# Execute command in shadow
amplifier-shadow exec SHADOW_ID COMMAND
  --timeout INTEGER   Timeout in seconds (default: 300)

# Show changed files
amplifier-shadow diff SHADOW_ID [PATH]

# Extract file from shadow
amplifier-shadow extract SHADOW_ID CONTAINER_PATH HOST_PATH

# Inject file into shadow
amplifier-shadow inject SHADOW_ID HOST_PATH CONTAINER_PATH

# List all shadows
amplifier-shadow list

# Show shadow status
amplifier-shadow status SHADOW_ID

# Destroy shadow
amplifier-shadow destroy SHADOW_ID
  --force             Force destruction even on errors

# Destroy all shadows
amplifier-shadow destroy-all
  --force             Force destruction even on errors

# Build shadow image locally
amplifier-shadow build

# Open interactive shell
amplifier-shadow shell SHADOW_ID

速查卡 [LEVEL 1]

# Typical workflow
amplifier-shadow create --local ~/repos/lib:org/lib --name test
amplifier-shadow exec test "pytest"
amplifier-shadow destroy test

# Multi-repo
amplifier-shadow create \
  --local ~/repos/lib1:org/lib1 \
  --local ~/repos/lib2:org/lib2 \
  --name multi

# With environment variables
amplifier-shadow create \
  --local ~/repos/lib:org/lib \
  --env API_KEY=$API_KEY \
  --name test

# Interactive shell
amplifier-shadow shell test

# Extract results
amplifier-shadow extract test /workspace/results ./local-results

相关技能 [LEVEL 1]

  • qa-team:在影子环境中运行 Agent 测试(旧名称:outside-in-testing)
  • test-gap-analyzer:查找未经测试的代码路径(补充影子测试)
  • philosophy-guardian:验证影子脚本是否遵循极致简洁原则

故障排除清单 [LEVEL 2]

影子测试失败时:

  • 确认正在使用本地源码(检查快照提交)
  • 检查预克隆的仓库是否存在于 /workspace/{org}/{repo}
  • 确认已传递环境变量(在影子环境中运行 env)
  • 如果包管理器缓存已过期,请清除缓存
  • 检查是否已配置 Git URL 重写(git config --list)
  • 确认 Gitea 可以访问(curl http://localhost:3000/api/v1/version)
  • 使用虚拟环境(避免 PEP 668 错误)
  • 检查容器是否正在运行(amplifier-shadow status)

更新日志 [LEVEL 3]

版本 1.0.0(2026-01-29)
  • 首次发布技能
  • 支持 Amplifier、Claude Code、GitHub Copilot 和手动 DIY
  • 提供可独立使用的 Shell 脚本
  • 提供用于 CI 集成的 Docker Compose 示例
  • 提供完整的 CLI 参考和故障排除指南
  • 提供与 qa-team / outside-in-testing 别名的集成模式
  • 理念与极致简洁原则保持一致

请记住:影子环境可让你在干净、隔离的环境中,测试你机器上的所有实际内容(包括未提交的更改),并模拟 CI 环境。每次重要推送前都应使用影子环境,以便及早发现问题。

评论

支持 Markdown