Skip to content
boundary-observation logo

Boundary Observation(境界条件観測)

boundary-observation

境界条件・エッジケースの観測。null/空/0/最大値/最小値/オーバーフロー/タイムゾーン等を網羅的にテスト。Use when: テスト設計、バリデーション実装、パーサー実装、日付/金額処理、例は通るが端で壊れる疑い、バグ修正後の再発防止。

SKILL.md

Full skill instructions

Boundary Observation(境界条件観測)

目的

生成コードは「平均的なケースに強く、端に弱い」傾向がある。 このスキルは、入力空間の端での欠陥を発見し、自己欺瞞を崩す。

観測の恩恵

  • "未知の未知"を減らす(狙っていない入力で壊す)
  • 境界条件が「仕様に昇格」し、次回生成の精度が上がる
  • バグが潜伏しやすい箇所(パーサ、日付、金額、状態遷移)が早く炙り出せる

Procedure

Step 1: 外部境界の特定

対象コードの「外部境界」を列挙する。

外部境界の例:

  • API入力(リクエストパラメータ)
  • DB境界(クエリ結果、NULL可能性)
  • ファイル境界(サイズ、エンコーディング)
  • 時間境界(タイムゾーン、DST、うるう年)
  • 数値境界(0、負数、最大値、オーバーフロー)

Step 2: 境界値テストの設計

各外部境界に対して、以下のテストケースを設計する:

カテゴリテストケース
最小値下限値、下限-1
最大値上限値、上限+1
空/​nullnull、空文字、空配列
異常値不正な型、不正なフォーマット

Step 3: プロパティベーステスト(性質テスト)

重要なロジックに対して、期待値に依存しない性質テストを1本以上設計する。

検証すべき性質の例:

  • 単調性: f(a) ≤ f(b) if a ≤ b
  • 可逆性: decode(encode(x)) == x
  • 冪等性: f(f(x)) == f(x)
  • 保存則: sum(before) == sum(after)
  • 交換律: f(a, b) == f(b, a)

Step 4: ファズテスト(必要に応じて)

以下のコンポーネントには特にファズテストが効く:

  • パーサー
  • デコーダー
  • 正規化処理
  • 文字コード変換

Step 5: 入力分布の観測(運用時)

実際にどんな値が来ているかを観測し、テストケースを補強する。

最小セット

  • (B1) 境界値テスト:外部境界ごとに「最小・最大・空・異常」
  • (B2) 重要ロジックに1つだけでも"性質テスト"を入れる

境界値カタログ

詳細は references/​boundary-catalog.md を参照。

Outputs

  • 境界値テストコード
  • プロパティテストコード(QuickCheck / Hypothesis / fast-check 等)
  • ファズテスト設定(必要に応じて)

Examples

日付処理の境界値テスト

# 境界値テスト
@pytest.mark.parametrize("date_str,expected", [
    ("2024-01-01", date(2024, 1, 1)),      # 通常
    ("2024-02-29", date(2024, 2, 29)),     # うるう年
    ("2023-02-29", ValueError),            # 非うるう年 → 異常
    ("", ValueError),                      # 空文字
    (None, TypeError),                     # null
    ("9999-12-31", date(9999, 12, 31)),   # 最大年
])
def test_parse_date_boundaries(date_str, expected):
    ...

金額計算のプロパティテスト

# 性質テスト: 金額の加算は交換律を満たす
from hypothesis import given, strategies as st

@given(st.integers(min_value=0), st.integers(min_value=0))
def test_add_money_commutative(a, b):
    assert add_money(a, b) == add_money(b, a)

# 性質テスト: 割引後の金額は元の金額以下
@given(st.integers(min_value=0, max_value=1000000), st.floats(min_value=0, max_value=1))
def test_discount_reduces_price(price, discount_rate):
    result = apply_discount(price, discount_rate)
    assert result <= price

More Other skills

Delegate independent tasks to specialized agents working concurrently with isolated context.

295.4K 206.3K
View

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

179.7K 100.1K
View

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

179.7K 89.5K
View

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

179.7K 76.1K
View

Fundamental design principles for writing maintainable, testable Python code.

40.2K 21.9K
View

Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.

40.2K 20K
View

Generate Playwright tests from scenarios using interactive browser exploration and validation.

39.7K 18.2K
View

Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.

40.2K 14.7K
View

GDPR-compliant data handling with consent management, data subject rights, and privacy controls.

40.2K 14.3K
View

Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.

40.2K 13.5K
View

Detailed multi-file refactor planning with safety checks and rollback guidance.

39.7K 13K
View