Community编程与开发github.com

alfathafp/portofolio-web-design

记录决策和文档。当你需要记录架构决策(ADR)或设计选择背后的理由、更改公共 API、发布功能,或需要为未来的工程师和代理记录理解代码库所需的上下文时,请使用此技能。

portofolio-web-design 是什么?

该技能专注于将设计与开发过程中的决策和文档进行系统化管理。它通过架构决策记录(ADR)来捕获技术决策背后的“为什么”,包括上下文、约束和权衡,从而避免未来的重复讨论和错误假设。它支持记录架构决策、公共 API 变更、功能发布,以及为未来的人类工程师和 AI 代理提供理解代码库所需的上下文。该技能提供了完整的 ADR 模板、生命周期管理、内联文档最佳实践(如注释“为什么”而非“什么”)、API 文档编写指南、README 结构以及变更日志维护方法。它还特别强调了对 AI 代理的支持,包括 CLAUDE.md 规则文件、规格文件和内联陷阱的维护,确保代理能够遵循项目约定并避免已知陷阱。最后的验证清单帮助确保文档的完整性和准确性。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/alfathafp/portofolio-web-design/tree/HEAD/.agents/skills/documentation-and-adrs

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

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

文档

文档与架构决策记录 (ADR)

概述

记录决策,而不仅仅是代码。最有价值的文档捕获的是 为什么 —— 导致某个决策的上下文、约束和权衡。代码展示的是 什么 被构建;文档解释的是 为什么这样构建 以及 考虑过哪些替代方案。这些上下文对于未来在代码库中工作的人类和代理至关重要。

何时使用

  • 做出重要的架构决策时
  • 在竞争方案之间做出选择时
  • 添加或更改公共 API 时
  • 发布改变用户行为的功能时
  • 新团队成员(或代理)加入项目时
  • 当你发现自己反复解释同一件事时

何时不用: 不要记录显而易见的代码。不要添加重述代码含义的注释。不要为一次性原型编写文档。

架构决策记录 (ADR)

ADR 捕获重要技术决策背后的推理。这是你能编写的最有价值的文档。

何时编写 ADR

  • 选择框架、库或主要依赖时
  • 设计数据模型或数据库模式时
  • 选择认证策略时
  • 决定 API 架构时(REST vs. GraphQL vs. tRPC)
  • 选择构建工具、托管平台或基础设施时
  • 任何撤销成本高昂的决策

首先匹配现有约定

在创建 ADR 之前,检查可用的仓库上下文以寻找既定约定 — 现有的 ADR、项目说明以及 ADR 相关的配置或工具(例如 .adr-dir 文件)。既定的约定会覆盖下面的默认值。匹配:

  • 位置与格式 — 例如 docs/adr/*.md,Documentation/Decisions/*.rst,MADR 布局,或 adr-tools 设置。匹配现有的目录、文件扩展名和标记格式(Markdown vs reStructuredText)。
  • 编号与命名 — 延续现有的序列和文件名模式(ADR-004-Title.rst,0004-title.md,……);不要从 001 重新开始或引入第二种方案。
  • 章节标题 — 复用项目的标题集,而不是强加此模板的标题。

如果现有证据存在冲突,应揭示冲突而不是默默引入另一种方案。仅在无法确定任何约定时,才应用下面的默认模板。

ADR 模板

将 ADR 存储在 docs/decisions/ 中,并使用顺序编号(除非项目已使用其他位置 — 见上文):

# ADR-001:使用 PostgreSQL 作为主数据库

## 状态
已提议 | 已接受 | 被 ADR-XXX 取代 | 已弃用

## 日期
2025-01-15

## 上下文
我们需要一个主数据库用于任务管理应用。关键需求:
- 关系型数据模型(用户、任务、团队及其关系)
- 任务状态变更的 ACID 事务
- 支持任务内容的全文搜索
- 提供托管服务(对于小团队、有限运维能力)

## 决策
使用 PostgreSQL 和 Prisma ORM。

## 考虑的替代方案

### MongoDB
- 优点:灵活的模式,易于上手
- 缺点:我们的数据本质上具有关系性;需要手动管理关系
- 被拒绝:在文档存储中处理关系型数据会导致复杂的连接或数据重复

### SQLite
- 优点:零配置,嵌入式,读取速度快
- 缺点:并发写入支持有限,生产环境无托管服务
- 被拒绝:不适合多用户 Web 应用的生产环境

### MySQL
- 优点:成熟,广泛支持
- 缺点:PostgreSQL 具有更好的 JSON 支持、全文搜索和生态工具
- 被拒绝:PostgreSQL 更符合我们的功能需求

## 后果
- Prisma 提供类型安全的数据库访问和迁移管理
- 我们可以使用 PostgreSQL 的全文搜索,而无需添加 Elasticsearch
- 团队需要掌握 PostgreSQL 知识(标准技能,风险低)
- 托管在托管服务上(Supabase、Neon 或 RDS)

ADR 生命周期

已提议 → 已接受 → (被取代 或 已弃用)
  • 不要删除旧的 ADR。 它们记录了历史上下文。
  • 当决策发生变化时,编写一个新的 ADR,引用并取代旧的 ADR。

内联文档

何时注释

注释 为什么,而不是 什么:

// 差:重述代码
// 将计数器加 1
counter += 1;

// 好:解释非显而易见的意图
// 限流使用滑动窗口 — 在窗口边界重置计数器,
// 而非固定时间表,以防止窗口边缘的突发攻击
if (now - windowStart > WINDOW_SIZE_MS) {
  counter = 0;
  windowStart = now;
}

何时不注释

// 不要注释不言自明的代码
function calculateTotal(items: CartItem[]): number {
  return items.reduce((sum, item) => sum + item.price * item.quantity, 0);
}

// 不要留下本应立即完成的 TODO 注释
// TODO:添加错误处理  ← 直接加上

// 不要留下注释掉的代码
// const oldImplementation = () => { ... }  ← 删除它,git 有历史记录

记录已知陷阱

/**
 * 重要:此函数必须在首次渲染前调用。
 * 如果在水合后调用,会导致无样式内容的闪烁,
 * 因为在服务端渲染期间主题上下文不可用。
 *
 * 有关完整的设计原理,请参见 ADR-003。
 */
export function initializeTheme(theme: Theme): void {
  // ...
}

API 文档

对于公共 API(REST、GraphQL、库接口):

内联类型(TypeScript 首选)

/**
 * 创建一个新任务。
 *
 * @param input - 任务创建数据(标题必填,描述可选)
 * @returns 创建的任务,包含服务器生成的 ID 和时间戳
 * @throws {ValidationError} 如果标题为空或超过 200 个字符
 * @throws {AuthenticationError} 如果用户未认证
 *
 * @example
 * const task = await createTask({ title: '买杂货' });
 * console.log(task.id); // "task_abc123"
 */
export async function createTask(input: CreateTaskInput): Promise<Task> {
  // ...
}

REST API 的 OpenAPI / Swagger

paths:
  /api/tasks:
    post:
      summary: 创建任务
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskInput'
      responses:
        '201':
          description: 任务已创建
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '422':
          description: 验证错误

README 结构

每个项目都应有一个包含以下内容的 README:

# 项目名称

一段说明该项目功能的描述。

## 快速开始
1. 克隆仓库
2. 安装依赖:`npm install`
3. 设置环境:`cp .env.example .env`
4. 启动开发服务器:`npm run dev`

## 命令
| 命令 | 说明 |
|---------|-------------|
| `npm run dev` | 启动开发服务器 |
| `npm test` | 运行测试 |
| `npm run build` | 生产环境构建 |
| `npm run lint` | 运行代码检查 |

## 架构
简要概述项目结构和关键设计决策。
有关详细信息,请链接到 ADR。

## 贡献
如何贡献、编码规范、PR 流程。

变更日志维护

对于已发布的功能:

# 变更日志

## [1.2.0] - 2025-01-20
### 新增
- 任务共享:用户可以与团队成员共享任务 (#123)
- 任务分配的邮件通知 (#124)

### 修复
- 快速点击创建按钮时出现重复任务 (#125)

### 变更
- 任务列表现在每页加载 50 个项目(之前是 20 个)以提升用户体验 (#126)

面向代理的文档

针对 AI 代理上下文的特殊考虑:

  • CLAUDE.md / 规则文件 — 记录项目约定,以便代理遵循
  • 规格文件 — 保持规格更新,使代理构建正确的内容
  • ADR — 帮助代理理解过去决策的原因(防止重新决策)
  • 内联陷阱 — 防止代理陷入已知陷阱

文字审阅

检查技术内容后,审阅文字的使用者体验。更清晰的措辞不得改变决策或其限制。

  1. 标记必须在编辑中保留的细节:名称、数字和单位、命令、路径、链接、条件、权衡和不确定性。对照可用的代码和决策上下文检查它们;标记任何无法证实的内容。
  2. 用读者需要的具体信息替换模板化的引言、宣传性形容词和重复的摘要。不要用编造的例子或更强有力的保证替换未经证实的说法。保留必要的技术重复和项目既定的术语。
  3. 将编辑后的文档与原文及其来源进行比较。恢复任何丢失的限定词或警告,验证命令和代码示例仍按文档工作,并解释任何未解决的事实问题,而不是美化掉它。

常见借口

借口现实
“代码本身就是文档”代码显示什么,但不显示为什么、哪些替代方案被拒绝或存在哪些约束。
“API 稳定后我们再写文档”当你编写文档时,API 会更快稳定。文档是对设计的第一次测试。
“没人读文档”代理会读。未来的工程师会读。三个月后的你自己也会读。
“ADR 是额外开销”一个 10 分钟的 ADR 可以防止六个月后关于同一决策的 2 小时辩论。
“注释会过时”关于 为什么 的注释是稳定的。关于 什么 的注释会过时 — 这就是为什么你只写前者的原因。

红旗

  • 无书面理由的架构决策
  • 没有文档或类型的公共 API
  • 未说明如何运行项目的 README
  • 注释掉的代码而非删除
  • 存在数周的 TODO 注释
  • 存在重大架构选择的项目中没有 ADR
  • 重述代码而非解释意图的文档

验证

文档编写后:

  • 所有重大架构决策都有相应的 ADR
  • README 涵盖快速开始、命令和架构概述
  • API 函数具有参数和返回类型的文档
  • 已知陷阱已在其影响位置内联记录
  • 没有注释掉的代码残留
  • 规则文件(CLAUDE.md 等)是最新且准确的
  • 文字编辑保留了源细节、决策权衡和限定词,没有添加未经支持的保证

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

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

Delivers changes incrementally in thin, verifiable slices. Use when implementing any feature or change that touches more than one file, or when picking up the next task from a plan. Use when rolling a change out behind a feature flag, when you're about to write a large amount of code at once, or when a task feels too big to land in one step.

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.

相关技能