Communitygithub.com

alfathafp/portofolio-web-design

当开始需要与当前工作空间隔离的功能开发或在执行实施计划之前使用——确保通过原生工具或 git worktree 回退方案存在一个隔离的工作空间。

portofolio-web-design 是什么?

该技能确保开发者或 AI 智能体在隔离的工作空间中开始工作,防止对当前分支产生意外修改。它首先检测是否已经处于隔离状态(例如,已存在的 git worktree),并处理子模块的边界情况。如果没有现成的隔离环境,它会优先使用平台原生的 worktree 工具,仅在原生工具不可用时,才通过手动 `git worktree add` 命令创建隔离工作区。此技能还负责项目依赖的自动安装和基线测试的验证,确保工作空间干净且可用。它支持从 Step 0 到 Step 3 的完整工作流,并包含安全检查和回退机制,比如在被沙箱拒绝时原地工作。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/using-git-worktrees

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

使用 Git Worktrees

概述

确保工作在隔离的工作空间中进行。优先使用平台的原生 worktree 工具。仅在没有原生工具可用时,回退到手动 git worktree 操作。

核心原则: 首先检测现有的隔离。然后使用原生工具。最后回退到 git。绝不与工具链对抗。

开始时声明: "我正在使用 using-git-worktrees 技能来设置一个隔离的工作空间。"

步骤 0:检测现有隔离

在创建任何内容之前,检查您是否已经处于隔离的工作空间中。

GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)

子模块保护: GIT_DIR != GIT_COMMON 在 git 子模块中也成立。在得出“已在 worktree 中”的结论之前,请验证您不在子模块中:

# 如果这返回一个路径,则说明您在子模块中,而不是 worktree —— 当作普通仓库处理
git rev-parse --show-superproject-working-tree 2>/dev/null

如果 GIT_DIR != GIT_COMMON(并且不是子模块): 您已经在一个链接的 worktree 中。跳到步骤 2(项目设置)。不要再创建另一个 worktree。

根据分支状态报告:

  • 在某个分支上:"已在隔离工作空间 <path>,分支为 <name>。"
  • 分离头指针:"已在隔离工作空间 <path>(分离头指针,外部管理)。完成时需要创建分支。"

如果 GIT_DIR == GIT_COMMON(或在子模块中): 您处于普通的仓库检出状态。

用户的指令中是否已经指出了他们的 worktree 偏好?如果没有,请在创建 worktree 之前征求同意:

"您是否希望我建立一个隔离的 worktree?它可以保护您当前分支的更改。"

尊重任何已声明的现有偏好,无需询问。如果用户拒绝同意,则在原地工作并跳到步骤 2。

步骤 1:创建隔离工作空间

您有两种机制。请按此顺序尝试。

1a. 原生 Worktree 工具(首选)

用户已要求一个隔离的工作空间(步骤 0 同意)。您是否已经有创建 worktree 的工具?它可能是一个名称类似 EnterWorktree、WorktreeCreate、/worktree 命令或带有 --worktree 标志的工具。如果有,请使用它并跳到步骤 2。

原生工具会自动处理目录放置、分支创建和清理。在有原生工具的情况下使用 git worktree add 会在您的工具链中创建不可见且无法管理的幽灵状态。

只有在没有原生 worktree 工具可用时才继续到步骤 1b。

1b. Git Worktree 回退方案

仅当步骤 1a 不适用时使用此方案——您没有可用的原生 worktree 工具。使用 git 手动创建 worktree。

目录选择

按此优先级顺序。用户的明确偏好总是优先于观察到的文件系统状态。

  1. 检查您的指令中是否有声明的 worktree 目录偏好。 如果用户已经指定了一个,直接使用,无需询问。

  2. 检查项目本地是否存在 worktree 目录:

    ls -d .worktrees 2>/dev/null     # 首选(隐藏)
    ls -d worktrees 2>/dev/null      # 备选
    

    如果找到,使用它。如果两者都存在,.worktrees 优先。

  3. 如果没有其他指导可用,默认为项目根目录下的 .worktrees/。

安全检查(仅限项目本地目录)

在创建 worktree 之前必须验证目录是否被忽略:

git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null

如果未被忽略: 添加到 .gitignore,提交更改,然后继续。

为什么关键: 防止意外地将 worktree 内容提交到仓库。

创建 Worktree

# 根据所选位置确定路径
path="$LOCATION/$BRANCH_NAME"

git worktree add "$path" -b "$BRANCH_NAME"
cd "$path"

沙箱回退: 如果 git worktree add 因权限错误(沙箱拒绝)而失败,告知用户沙箱阻止了 worktree 创建,您将在当前目录中工作。然后在原地运行设置和基线测试。

步骤 2:项目设置

自动检测并运行适当的设置:

# Node.js
if [ -f package.json ]; then npm install; fi

# Rust
if [ -f Cargo.toml ]; then cargo build; fi

# Python
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f pyproject.toml ]; then poetry install; fi

# Go
if [ -f go.mod ]; then go mod download; fi

步骤 3:验证干净基线

运行测试以确保工作空间从干净状态开始:

# 使用项目合适的命令
npm test / cargo test / pytest / go test ./...

如果测试失败: 报告失败情况,询问是继续还是调查。

如果测试通过: 报告准备就绪。

报告

Worktree ready at <full-path>
Tests passing (<N> tests, 0 failures)
Ready to implement <feature-name>

快速参考

情况操作
已在链接的 worktree 中跳过创建(步骤 0)
在子模块中当作普通仓库处理(步骤 0 保护)
原生 worktree 工具可用使用它(步骤 1a)
无原生工具Git worktree 回退方案(步骤 1b)
.worktrees/ 存在使用它(验证忽略状态)
worktrees/ 存在使用它(验证忽略状态)
两者都存在使用 .worktrees/
都不存在检查指令文件,然后默认使用 .worktrees/
目录未被忽略添加到 .gitignore + 提交
创建时权限错误沙箱回退,原地工作
测试在基线阶段失败报告失败 + 询问
没有 package.json/Cargo.toml跳过依赖安装

常见合理化借口

借口现实
"我显然不在 worktree 中——无需检查"执行步骤 0。工具链创建的隔离和子模块都能蒙蔽肉眼;检测命令才能确定。
"git worktree add 比寻找原生工具更快"原生工具(例如 EnterWorktree)管理放置、分支和清理。绕过它是 #1 错误——它会在您的工具链中创建不可见且无法管理的幽灵状态。
"worktree 目录肯定已经被忽略了"运行 git check-ignore。未忽略的 worktree 目录会将整个树提交到仓库中。
"任何目录名都行"明确的指令优先于现有的项目本地目录,现有项目本地目录优先于 .worktrees/ 默认值。
"工作空间是全新的——基线测试可以等等"脏的基线会使每个后续失败都不明确。现在就运行测试;是否在失败后继续是您人类伙伴的决定。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

alfathafp/portofolio-web-design

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).

alfathafp/portofolio-web-design

Tests in real browsers via Chrome DevTools MCP. Use when building or debugging anything that runs in a browser. Use when you need to inspect the DOM, capture console errors, analyze network requests, profile performance, or verify visual output with real runtime data. Requires the chrome-devtools MCP server to be configured.

alfathafp/portofolio-web-design

Automates CI/CD pipeline setup. Use when setting up or modifying build and deployment pipelines. Use when you need to automate quality gates, configure test runners in CI, or establish deployment strategies.

alfathafp/portofolio-web-design

Conducts multi-axis code review. Use before merging any change. Use when reviewing code written by yourself, another agent, or a human. Use when you need to assess code quality across multiple dimensions before it enters the main branch. Use when asked to review a diff or a pull request, even when the diff is pasted inline.

alfathafp/portofolio-web-design

Simplifies code for clarity. Use when refactoring code for clarity without changing behavior. Use when code works but is harder to read, maintain, or extend than it should be. Use when reviewing code that has accumulated unnecessary complexity.

alfathafp/portofolio-web-design

Establishes a project's quality bar as a written contract and stops agents quietly lowering it. Interviews the user on which dimensions matter, supplies sane default thresholds when they have no number in mind, records everything in CONSTRAINTS.md, and watches the diff for a weakened bar — new @ts-ignore or eslint-disable suppressions, skipped or deleted tests, assertions stripped out, unimplemented stubs, thresholds edited down. Use when no quality bar is written down, when the user says "set up constraints" or "define our standards", when the user wants dimensions they care about — accessibility, web performance, coverage — set up as enforced constraints, when an agent keeps silencing checks or skipping tests to get to green, when you need a coverage or performance threshold and don't know what number to pick, or when an agent writes more code than anyone will read.

alfathafp/portofolio-web-design

Optimizes agent context setup. Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

alfathafp/portofolio-web-design

Guides systematic root-cause debugging. Use when tests fail, builds break, something that worked yesterday broke, behavior doesn't match expectations, or you encounter any unexpected error. Use when you need to figure out what broke and why — a systematic approach to finding and fixing the root cause rather than guessing.

alfathafp/portofolio-web-design

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

alfathafp/portofolio-web-design

Manages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.

alfathafp/portofolio-web-design

Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.

alfathafp/portofolio-web-design

Use when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies

alfathafp/portofolio-web-design

Records decisions and documentation. Use when you need to document an architecture decision (ADR) or the reasoning behind a design choice, when changing public APIs, shipping features, or when you need to record context that future engineers and agents will need to understand the codebase.

alfathafp/portofolio-web-design

Subjects every non-trivial decision to a fresh-context adversarial review before it stands. Use when you want every assumption cross-examined before proceeding, when stress-testing a plan for hidden failure modes, when correctness matters more than speed, when working in unfamiliar code, when stakes are high (production auth, security-sensitive logic, a high-stakes migration, irreversible operations), or any time a confident output would be cheaper to verify now than to debug later.

alfathafp/portofolio-web-design

Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available

alfathafp/portofolio-web-design

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work

alfathafp/portofolio-web-design

Builds production-quality, accessible, responsive user-facing UIs. Use when building or modifying interfaces and pages, creating components, implementing layouts, meeting WCAG accessibility requirements, managing state, or when the output needs to look and feel production-quality rather than AI-generated.

alfathafp/portofolio-web-design

Structures git workflow practices. Use when making any code change. Use when committing, branching, resolving conflicts, splitting uncommitted work in a messy working tree into clean atomic commits, opening or reviewing a pull request (PR), pushing to a remote, or when you need to organize work across multiple parallel streams. Use when cutting a release, choosing a semantic version bump, tagging, or writing a changelog.

alfathafp/portofolio-web-design

Refines raw ideas into sharp, actionable concepts through structured divergent and convergent thinking. Use when an idea is still vague, when you need to stress-test assumptions before committing to a plan, or when you want to expand options before converging on one. Triggers on "ideate", "refine this idea", or "stress-test my plan".

alfathafp/portofolio-web-design

Guides stable API and interface design. Use when designing APIs, module boundaries, or any public interface. Use when creating REST or GraphQL endpoints, defining type contracts between modules, or establishing boundaries between frontend and backend.

相关技能