Context7 Tddのロゴ

Context7 Tdd

コミュニティ
VenTheZone
context7-tdd

Test-Driven Development powered by Context7 documentation. Write tests based on official library docs, verify implementations against authoritative sources.

概要

公開者VenTheZone
リポジトリpi-dots
スキル名context7-tdd
スター
41
フォーク
0
同梱ファイル
指示のみ
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    VenTheZoneがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルContext7 TddをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/VenTheZone/pi-dots/tree/main/pi-dotfiles-niche-skills/skills/context7-tdd
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/VenTheZone/pi-dots.git /tmp/pi-dots
mkdir -p .claude/skills
cp -r /tmp/pi-dots/pi-dotfiles-niche-skills/skills/context7-tdd .claude/skills/context7-tdd
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでContext7 Tddを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にContext7 Tddを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Context7 Tddは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

Context7-Driven TDD

Combine Context7 documentation lookup with Test-Driven Development to ensure your code matches official library patterns from the start.

Core Workflow

1. Research Phase (Context7 First)

Before writing any test, query Context7 for the library/framework you're testing against:

When to query:

  • Testing a new library integration
  • Unsure about API behavior or edge cases
  • Working with complex APIs (ORMs, auth, payments)
  • Version-specific behavior matters

How to query:

1. Identify dependencies from package.json/imports
2. If Context7 tools are available, use context7_resolve-library-id to get the library ID
3. If Context7 tools are available, use context7_query-docs for specific "how to" questions
4. Otherwise use official docs, project docs, or web search to gather the same guidance manually
5. Focus on: initialization patterns, error handling, best practices

Example queries:

  • "How to set up JWT authentication with NextAuth.js"
  • "React useEffect cleanup function examples"
  • "Express.js middleware error handling patterns"
  • "How to handle transactions in TypeORM"

2. Test Design Phase

Based on Context7 documentation, design tests that verify:

Happy Path:

  • Does it follow the documented initialization pattern?
  • Are we using the API correctly per official docs?

Error Cases:

  • What errors does the library throw? (check docs)
  • How should we handle edge cases?

Integration Points:

  • Does our code match the library's expected input/output?
  • Are we following documented best practices?

3. Write Tests (Red Phase)

Write failing tests that assert behavior according to official documentation:

typescript
// Example: Testing React Query based on Context7 docs
import { renderHook, waitFor } from '@testing-library/react';
import { useQuery } from '@tanstack/react-query';

describe('useUserData', () => {
  it('should cache data according to React Query best practices', async () => {
    // Test based on documented caching behavior
    const { result } = renderHook(() => useUserData('123'));
    
    await waitFor(() => expect(result.current.isSuccess).toBe(true));
    
    // Verify caching behavior matches official docs
    expect(result.current.data).toEqual(mockUserData);
  });
  
  it('should handle errors as documented in React Query', async () => {
    // Test error handling patterns from official docs
    server.use(
      rest.get('/api/user/123', (req, res, ctx) => {
        return res(ctx.status(404));
      })
    );
    
    const { result } = renderHook(() => useUserData('123'));
    
    await waitFor(() => expect(result.current.isError).toBe(true));
    expect(result.current.error).toBeInstanceOf(Error);
  });
});

4. Implement (Green Phase)

Write minimal implementation that satisfies tests AND follows Context7 docs:

typescript
// Implementation following Context7-verified patterns
import { useQuery } from '@tanstack/react-query';

export function useUserData(userId: string) {
  return useQuery({
    queryKey: ['user', userId],
    queryFn: async () => {
      const response = await fetch(`/api/user/${userId}`);
      if (!response.ok) {
        throw new Error('Failed to fetch user');
      }
      return response.json();
    },
    // Configuration based on Context7-verified best practices
    staleTime: 5 * 60 * 1000, // 5 minutes
    retry: 3,
  });
}

5. Refactor Phase

After tests pass, verify against Context7 docs:

Checklist:

  • Does the implementation match official examples?
  • Are we using the recommended error handling?
  • Is our configuration following best practices?
  • Query Context7 again if unsure about refactoring direction

Common Patterns

Pattern: Testing Database Operations

typescript
// Query Context7 first: "How to use Prisma with transactions"
// Then write tests:

describe('createOrder', () => {
  it('should use transaction for order creation', async () => {
    const orderData = { /* ... */ };
    
    await createOrder(orderData);
    
    // Verify transaction was used (check logs or mock)
    expect(prisma.$transaction).toHaveBeenCalled();
  });
  
  it('should rollback on failure', async () => {
    // Simulate failure condition
    jest.spyOn(prisma.order, 'create').mockRejectedValue(new Error('DB error'));
    
    await expect(createOrder(orderData)).rejects.toThrow();
    
    // Verify rollback occurred
    expect(prisma.$transaction).toHaveBeenCalledWith(
      expect.arrayContaining([expect.any(Promise)])
    );
  });
});

Pattern: Testing API Integrations

typescript
// Query Context7: "How to handle rate limiting in Stripe API"

describe('createStripeCustomer', () => {
  it('should handle Stripe rate limiting', async () => {
    // Mock rate limit response based on Stripe docs
    stripeMock.customers.create.mockRejectedValue({
      type: 'StripeRateLimitError',
      headers: { 'retry-after': '2' }
    });
    
    // Implementation should retry per Stripe best practices
    await expect(createStripeCustomer(data)).rejects.toThrow();
    expect(stripeMock.customers.create).toHaveBeenCalledTimes(3); // Retry logic
  });
});

Pattern: Testing Authentication

typescript
// Query Context7: "How to implement JWT auth with NextAuth.js"

describe('authenticateUser', () => {
  it('should generate valid JWT per NextAuth spec', async () => {
    const user = await authenticateUser(credentials);
    
    // Verify JWT structure matches NextAuth documentation
    expect(user.token).toMatch(/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$/);
  });
});

Integration with Agent Workflow

When using the TDD guide agent with this skill:

  1. Agent queries Context7 before suggesting test structure
  2. Tests are designed to verify documented behavior
  3. Implementation follows official patterns verified by Context7
  4. Refactoring maintains compliance with authoritative docs

Tools Available

  • context7_resolve-library-id - Get Context7-compatible library ID
  • context7_query-docs - Query official documentation and examples
  • Standard testing tools (read, bash, write, edit)

Best Practices

  1. Always verify first - Don't assume API behavior; check Context7
  2. Test the interface - Tests verify your code uses the library correctly
  3. Version matters - Specify library versions in queries when relevant
  4. Cross-reference - If Context7 results are unclear, query again with different wording
  5. Document assumptions - Comment tests that rely on specific Context7-verified behavior

Example Session Flow

User: "I need to add Stripe payment processing"

Agent (with context7-tdd skill):
1. Query Context7: "How to create Stripe payment intents"
2. Design tests based on official Stripe patterns
3. Write failing tests (Red)
4. Implement minimal code following docs (Green)
5. Refactor while maintaining doc compliance
6. Run tests to verify

よくある質問

AIスキル「Context7 Tdd」では何ができますか?

Test-Driven Development powered by Context7 documentation. Write tests based on official library docs, verify implementations against authoritative sources.

TypingMindでContext7 Tddを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Context7 Tddはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにContext7 Tddをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/VenTheZone/pi-dots/tree/main/pi-dotfiles-niche-skills/skills/context7-tddを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Context7 Tddを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Context7 Tddは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもContext7 Tddを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Context7 Tdd」は無料ですか?

VenTheZoneがGitHubで公開しています。ライセンス条件はリポジトリでご確認ください。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇