Communitygithub.com

cdcoonce/Portfolio_Website

テスト駆動開発(レッド・グリーン・リファクターループ)。ユーザーがTDDを使用して機能の構築やバグ修正を行いたい場合、「レッド・グリーン・リファクター」に言及した場合、統合テストを希望する場合、またはテストファースト開発を依頼した場合に使用します。

Portfolio_Website とは?

このスキルは、テスト駆動開発(TDD)のベストプラクティスをエージェントに提供します。主な目的は、実装の詳細ではなくパブリックインターフェースを通じて振る舞いをテストすることに焦点を当て、良質な統合スタイルのテストを作成することです。水平スライシング(すべてのテストを先に書き、後で実装する)というアンチパターンを避け、垂直スライス(1つのテスト→1つの実装→繰り返し)を推奨します。ワークフローは計画、トレーサーブレット(最初のテストと最小限のコード)、インクリメンタルループ、リファクタリングのサイクルで構成され、各サイクルで「レッド(テスト失敗)→グリーン(テスト通過)→リファクター(コード改善)」の原則に従います。このスキルはClaude CodeやCodexなどのAIエージェントと連携し、コードベースに対してTDDを適切に適用するためのガイドラインを提供します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/cdcoonce/Portfolio_Website/tree/HEAD/.claude/skills/tdd

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

テスト駆動開発

哲学

核となる原則: テストは実装の詳細ではなく、パブリックインターフェースを通じて振る舞いを検証すべきです。コードは完全に変更される可能性がありますが、テストは変更されるべきではありません。

良いテストは統合スタイルです。パブリックAPIを通じて実際のコードパスを実行します。システムが_何を_行うかを記述し、_どのように_行うかは記述しません。良いテストは仕様のように読み取れます。「ユーザーは有効なカートでチェックアウトできる」というテストは、その機能が存在することを正確に示します。これらのテストは内部構造に関係しないため、リファクタリング後も生き残ります。

悪いテストは実装に結合しています。内部の協力者をモックし、プライベートメソッドをテストし、または外部手段(データベースにインターフェース経由ではなく直接クエリするなど)で検証します。警告サイン:リファクタリング時にテストが壊れるが、振る舞いは変わっていない場合。内部関数の名前を変更しただけでテストが失敗するなら、そのテストは実装をテストしており、振る舞いをテストしていません。

例についてはtests.mdを、モッキングのガイドラインについてはmocking.mdを参照してください。

アンチパターン:水平スライシング

すべてのテストを先に書き、その後すべての実装を書かないでください。 これは「水平スライシング」と呼ばれ、REDフェーズを「すべてのテストを書く」、GREENフェーズを「すべてのコードを書く」と扱うものです。

これにより質の悪いテストが生まれます:

  • まとめて書かれたテストは_実際の_振る舞いではなく、_想像上の_振る舞いをテストします
  • ユーザー向けの振る舞いではなく、データ構造や関数シグネチャといった_形状_をテストすることになります
  • テストは実際の変更に鈍感になります。振る舞いが壊れているのにテストがパスしたり、振る舞いが正しいのにテストが失敗したりします
  • 実装を理解する前にテスト構造にコミットしてしまい、先を見越しすぎます

正しいアプローチ: トレーサーブレットによる垂直スライス。1つのテスト→1つの実装→繰り返し。各テストは前のサイクルで学んだことに基づいて書かれます。コードを書いたばかりなので、どの振る舞いが重要で、それをどのように検証するかが正確に分かります。

間違い(水平):
  RED:   test1, test2, test3, test4, test5
  GREEN: impl1, impl2, impl3, impl4, impl5

正しい(垂直):
  RED→GREEN: test1→impl1
  RED→GREEN: test2→impl2
  RED→GREEN: test3→impl3
  ...

ワークフロー

1. 計画

コードを書く前に:

  • 必要なインターフェースの変更についてユーザーと確認する
  • テストすべき振る舞い(優先順位付き)をユーザーと確認する
  • 深いモジュール(小さなインターフェース、深い実装)の機会を特定する
  • テスト容易性のためのインターフェースを設計する
  • テストする振る舞い(実装手順ではない)をリストアップする
  • 計画についてユーザーの承認を得る

質問例:「パブリックインターフェースはどのようにすべきですか?どの振る舞いを最も重要にテストすべきですか?」

すべてをテストすることはできません。 どの振る舞いが最も重要かをユーザーと正確に確認してください。すべてのエッジケースではなく、クリティカルパスと複雑なロジックにテスト労力を集中させましょう。

2. トレーサーブレット

システムについて1つのことを確認するテストを1つ書きます:

RED:   最初の振る舞いのテストを書く → テストが失敗
GREEN: テストを通過させる最小限のコードを書く → テストが成功

これがトレーサーブレットです。パスがエンドツーエンドで機能することを証明します。

3. インクリメンタルループ

残りの各振る舞いについて:

RED:   次のテストを書く → 失敗
GREEN: 通過させる最小限のコードを書く → 成功

ルール:

  • 一度に1つのテスト
  • 現在のテストを通過させるのに十分なコードのみ
  • 将来のテストを先取りしない
  • テストは観測可能な振る舞いに集中させる

4. リファクタリング

すべてのテストが通過した後、リファクタリング候補を探します:

  • 重複を抽出する
  • モジュールを深くする(複雑さをシンプルなインターフェースの背後に移動)
  • 自然な場所でSOLID原則を適用する
  • 新しいコードが既存のコードについて何を明らかにするかを考える
  • 各リファクタリングステップの後にテストを実行する

REDの状態でリファクタリングしないでください。 まずGREENにしてください。

サイクルごとのチェックリスト

[ ] テストは実装ではなく振る舞いを記述している
[ ] テストはパブリックインターフェースのみを使用している
[ ] テストは内部リファクタリング後も生き残る
[ ] コードはこのテストに対して最小限である
[ ] 推測による機能追加がない

Individual skills in this repo

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

cdcoonce/Portfolio_Website

Git commit workflow with enforced conventional commit style. Use when Claude needs to stage and commit changes, craft commit messages, or the user asks to commit, make a commit, or save their work. Ensures consistent commit message format, proper scoping, and atomic commits across the project.

cdcoonce/Portfolio_Website

AI-powered code quality analysis for Python, Markdown, and Mermaid diagrams. Use this skill when: (1) reviewing code for quality issues, (2) checking Python files for PEP8 violations, unused code, missing type hints, docstring problems, complexity issues, or potential runtime errors, (3) validating Markdown documentation for broken links, heading structure, or formatting issues, (4) validating Mermaid diagram syntax, (5) the user asks for a "code review" or "quality check", (6) analyzing code snippets pasted in conversation, or (7) suggesting and applying fixes for code quality issues.

cdcoonce/Portfolio_Website

Deploy the portfolio chat agent Lambda function to AWS. Use when the user asks to deploy, redeploy, push to Lambda, update the chat agent, or after updating context files or lambda_function.py. Rebuilds the knowledge base, packages dependencies, and deploys to AWS Lambda.

cdcoonce/Portfolio_Website

Generate multiple radically different interface designs for a module using parallel sub-agents. Use when user wants to design an API, explore interface options, compare module shapes, or mentions "design it twice".

cdcoonce/Portfolio_Website

Orchestrate the full GitHub-issues-driven development lifecycle. 7-phase pipeline from brainstorm through PR with state tracking and cross-conversation resume. Use when user says "dev cycle", "development workflow", "full development pipeline", or invokes /dev-cycle.

cdcoonce/Portfolio_Website

Production Python coding standards with automatic version detection (3.10-3.13). Use when writing, reviewing, or refactoring Python to ensure adherence to modern type syntax, LBYL exception handling, pathlib operations, ABC-based interfaces, and production-tested patterns. Not Dagster-specific - applies to any Python project.

cdcoonce/Portfolio_Website

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.

cdcoonce/Portfolio_Website

GitHub CLI (gh) integration for managing issues, pull requests, branches,

cdcoonce/Portfolio_Website

Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".

cdcoonce/Portfolio_Website

Explore a codebase to find opportunities for architectural improvement, focusing on making the codebase more testable by deepening shallow modules. Use when user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more AI-navigable.

cdcoonce/Portfolio_Website

CEO/founder-mode plan review. Rethink the problem, find the 10-star product, challenge premises, expand scope when it creates a better product. Three modes: SCOPE EXPANSION (dream big), HOLD SCOPE (maximum rigor), SCOPE REDUCTION (strip to essentials). Use when the user asks for a plan review, CEO review, mega review, or wants a plan challenged/stress-tested before implementation.

cdcoonce/Portfolio_Website

Break a PRD into independently-grabbable GitHub issues using tracer-bullet vertical slices. Use when user wants to convert a PRD to issues, create implementation tickets, or break down a PRD into work items.

cdcoonce/Portfolio_Website

Turn a PRD into a multi-phase implementation plan using tracer-bullet vertical slices, saved as a local Markdown file in docs/plans/. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions "tracer bullets".

cdcoonce/Portfolio_Website

Generate or update the `.claude/docs/project.md` file that gives Claude project-specific context. Use this skill when the user asks to create, update, regenerate, or refresh project context, or says things like "update project.md", "generate project context", "this repo needs a project.md", or "Claude doesn't know about this project". Also trigger when onboarding Claude to a new repository for the first time.

cdcoonce/Portfolio_Website

Generate comprehensive, high-quality README.md files for code repositories. Use this skill whenever the user asks to create, write, generate, update, or improve a README for any project or repository. Also trigger when the user says things like "document this project", "write docs for this repo", "this repo needs a README", "help me onboard developers to this codebase", or asks for project documentation in markdown. Even if the user just says "README" or "readme" in the context of a codebase, use this skill.

cdcoonce/Portfolio_Website

Create a detailed refactor plan with tiny commits via user interview, then file it as a GitHub issue. Use when user wants to plan a refactor, create a refactoring RFC, or break a refactor into safe incremental steps.

cdcoonce/Portfolio_Website

Set up pre-commit hooks for the current repo. Use when user wants to add pre-commit hooks, configure commit-time linting, formatting, type checking, or testing. Triggers on "pre-commit", "git hooks", "linting hooks", or /setup-pre-commit.

cdcoonce/Portfolio_Website

Triage a bug or issue by exploring the codebase to find root cause, then create a GitHub issue with a TDD-based fix plan. Use when user reports a bug, wants to file an issue, mentions "triage", or wants to investigate and plan a fix for a problem.

cdcoonce/Portfolio_Website

Rewrites the prose sections of wiki pages in-place. Reads source files to understand current context, then updates only the content inside <!-- claude:prose --> ... <!-- claude:prose:end --> markers. Never touches <!-- generated:start --> ... <!-- generated:end --> blocks. Supports targeting a single page with /update-wiki {PageName}.

cdcoonce/Portfolio_Website

Create a PRD through user interview, codebase exploration, and module design, then submit as a GitHub issue. Use when user wants to write a PRD, create a product requirements document, or plan a new feature.

関連スキル