这是一篇由原始材料转换而来的阅读页,保留了源文件的主要结构,并补充了可追溯的来源说明与链接。

摘要

echo "[init.sh] repo: $(pwd)"

anthropicreference filetemplate / pattern
#!/usr/bin/env bash
set -euo pipefail

# init.sh (template)
# 目标:一键把项目拉到“可运行 + 可冒烟测试”的状态。
# 重要:这个脚本应该被每次新会话优先执行,用来验证仓库没有被留在坏状态。

echo "[init.sh] repo: $(pwd)"

if ! command -v git >/dev/null 2>&1; then
  echo "[init.sh] ERROR: git not found" >&2
  exit 1
fi

if [ ! -d .git ]; then
  echo "[init.sh] ERROR: not a git repo (no .git/)" >&2
  echo "[init.sh] Hint: run this script from the repository root." >&2
  exit 1
fi

# --- Customize below for your project ---
# Examples (pick one and delete the rest):
# - Node:   npm ci && npm test && npm run dev (in background) + curl smoke test
# - Python: uv sync / pip install -r requirements.txt + pytest + start server + curl
# - Go:     go test ./... + go run ./cmd/server + curl

echo "[init.sh] TODO: customize this script for your project (install deps, start server, smoke test)."

# Default: minimal sanity checks that are always safe.

git status --porcelain=v1

echo "[init.sh] OK (template only)"

来源与参考

源文件: anthropic/templates/init.sh

来源目录: /srv/project/harness-engineering

继续阅读