Loading...
Loading...
Compare original and translation side by side
ONBOARDING.mdREADME.mdCLAUDE.md.claude/settings.jsonONBOARDING.mdREADME.mdCLAUDE.md.claude/settings.json| 检查项 | 命令示例 | 失败处理 |
|---|---|---|
| git 状态 | | 提示用户配置 git identity |
| 系统依赖 | | 按 ONBOARDING.md 安装 |
| Python 环境 | | 用 uv 创建 venv |
| 项目依赖 | | 读取 pyproject.toml |
| 模型/二进制 | | 按文档下载/编译 |
| 环境变量 | | 指导用户填入或生成 |
uv| Check Item | Command Example | Failure Handling |
|---|---|---|
| Git Status | | Prompt user to configure git identity |
| System Dependencies | | Install according to ONBOARDING.md |
| Python Environment | | Create venv using uv |
| Project Dependencies | | Read pyproject.toml |
| Models/Binaries | | Download/compile according to documentation |
| Environment Variables | | Guide user to fill in or generate |
uvrm -rf|| truerm -rf|| trueuv run pytestuv run pytestgit pushgh repo view <owner>/<repo> --json visibility,isPrivate,stargazerCount,forkCountgh pr createisPrivate: truegit pushgh repo view <owner>/<repo> --json visibility,isPrivate,stargazerCount,forkCountgh pr createisPrivate: true.env/Users/<name>/--no-verify--no-gpg-sign--no-verify.env/Users/<name>/undefined--no-verify--no-gpg-sign--no-verifyundefined
- 占位符(`"your-key-here"`)只能在 `.env.example` 里,**永不**进真实代码
- 写完 LLM/API 客户端初始化后自查:`.env` 没加载会发生什么?能看见明文吗?
---ONBOARDING.mdundefined
- Placeholders (`"your-key-here"`) can only be in `.env.example`, **never** in real code
- After writing LLM/API client initialization, self-check: What happens if `.env` is not loaded? Can plaintext be seen?
---ffmpeg -versionuv --versionONBOARDING.mdundefineduv syncffmpeg -versionuv --versionuv run pytest tests/test_smoke.py -vuv sync.envuv run pytest tests/test_smoke.py -v
**要求**:
- 所有命令可直接复制执行(无个人路径、无假设)
- 使用相对路径或占位符(`<REPO_ROOT>`)
- 包含"验证"步骤,不只是"安装"步骤.env.claude/settings.json{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/session-start-check.sh"
}
]
}
]
}
}.claude/hooks/session-start-check.sh#!/usr/bin/env bash
CACHE_DIR="$HOME/.claude/cache/env-check"
mkdir -p "$CACHE_DIR"
REPO_HASH=$(cd "$(dirname "$0")/../.." && pwd | sha256sum | cut -d' ' -f1)
CACHE_FILE="$CACHE_DIR/$REPO_HASH"
if [ -f "$CACHE_FILE" ] && [ "$(find "$CACHE_FILE" -mtime -1 2>/dev/null)" ]; then
exit 0
fi
touch "$CACHE_FILE"
echo "【环境自检】你刚刚进入 [项目名] 仓库。请在执行任何任务前,先阅读 ONBOARDING.md 并按 Step 1-3 验证环境。"scripts/init_session_start_hook.pyundefined
**Requirements**:
- All commands can be copied and executed directly (no personal paths, no assumptions)
- Use relative paths or placeholders (`<REPO_ROOT>`)
- Include "verification" steps, not just "installation" steps.claude/settings.json{
"hooks": {
"SessionStart": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/session-start-check.sh"
}
]
}
]
}
}.claude/hooks/session-start-check.sh#!/usr/bin/env bash
CACHE_DIR="$HOME/.claude/cache/env-check"
mkdir -p "$CACHE_DIR"
REPO_HASH=$(cd "$(dirname "$0")/../.." && pwd | sha256sum | cut -d' ' -f1)
CACHE_FILE="$CACHE_DIR/$REPO_HASH"
if [ -f "$CACHE_FILE" ] && [ "$(find "$CACHE_FILE" -mtime -1 2>/dev/null)" ]; then
exit 0
fi
touch "$CACHE_FILE"
echo "【Environment Self-Check】You just entered the [Project Name] repository. Please read ONBOARDING.md and verify the environment according to Steps 1-3 before performing any tasks."scripts/init_session_start_hook.pyundefined
**脚本行为**:
1. 创建 `.claude/settings.json`(SessionStart hook 配置)
2. 创建 `.claude/hooks/session-start-check.sh`(24h 缓存 + 自检提示)
3. `--update-gitignore` 时追加规则,允许 `.claude/settings.json` 和 `hooks/` 入 git
4. 自动从 git remote 或目录名推断项目名
5. 已有配置时默认跳过(`--force-overwrite` 覆盖)
**设计原则**:
- hook 只负责**戳**agent 检查(输出提示),**不负责**复杂脚本检查
- 24h TTL 缓存降频(用 repo path sha256 作为 cache key)
- 项目级配置,与全局 settings deep merge
**Script Behavior**:
1. Create `.claude/settings.json` (SessionStart hook configuration)
2. Create `.claude/hooks/session-start-check.sh` (24h cache + self-check prompt)
3. When `--update-gitignore` is used, append rules to allow `.claude/settings.json` and `hooks/` to be included in git
4. Automatically infer project name from git remote or directory name
5. Skip by default if configuration already exists (use `--force-overwrite` to overwrite)
**Design Principles**:
- Hook only responsible for prompting the agent to check (output prompt), **not** responsible for complex script checks
- 24h TTL cache to reduce frequency (use repo path sha256 as cache key)
- Project-level configuration, deep merged with global settingsgit statusgit diffgit addgit add .git commit -m "..."Co-Authored-By: Claude <noreply@anthropic.com>git pushgit status<<<<<<<=======>>>>>>>git addgit commitgit statusgit diffgit addgit add .git commit -m "..."Co-Authored-By: Claude <noreply@anthropic.com>git pushgit checkout --orphan new-history
git add -A
git commit -m "Initial commit: sanitized history"
git push --force origin new-history:maingit status<<<<<<<=======>>>>>>>git addgit commit.envvideo-rough-cut-devgit checkout --orphan new-history
git add -A
git commit -m "Initial commit: sanitized history"
git push --force origin new-history:main/Users/<name>//home/<name>/<private-domain>.dev<private-domain>.pro<REPO_ROOT><USER_HOME><YOUR_NAME>.env.envvideo-rough-cut-dev~/.local/bincurl -LsSf https://astral.sh/uv/install.sh | sh/Users/<name>//home/<name>/<private-domain>.dev<private-domain>.pro<REPO_ROOT><USER_HOME><YOUR_NAME>.envbrew install ffmpegffmpeg-full~/.local/bincurl -LsSf https://astral.sh/uv/install.sh | shxcode-select --installbrew install ffmpegffmpeg-full.envxcode-select --install.envgit_safety.mdpii_guard.mdonboarding_template.mdcheck_env.pysanitize_history.shgit_safety.mdpii_guard.mdonboarding_template.mdcheck_env.pysanitize_history.sh