Memstack Development Test Writerのロゴ

Memstack Development Test Writer

コミュニティ
cwinvestments
memstack-development-test-writer

Use this skill when the user says 'write tests', 'add tests', 'test coverage', 'unit tests', 'integration tests', 'component tests', 'mocking', 'edge cases', or needs to generate tests with proper mocking and edge case coverage. Do NOT use for refactoring plans or database migrations.

概要

公開者cwinvestments
リポジトリmemstack
スキル名memstack-development-test-writer
スター
425
フォーク
45
同梱ファイル
指示のみ
ライセンスMIT
リンク
  • Markdown形式の指示

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

  • どのLLMでも利用可能

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

  • 指示だけで完結

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

  • オープンソース

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

インストール

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

1

TypingMindにインストール

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

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

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

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

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

TypingMindで使用

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

関連するリクエストがあるとすぐに、モデルが自動的にMemstack Development Test Writerを読み込みます。

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

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

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

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、スキルを使わない間は指示の読み込みにトークンを消費しません。

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

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

スキルの指示

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

Test Writer: Generating test suite...

Generates comprehensive test suites with unit, integration, and e2e tests, proper mocking strategies, edge case coverage, naming conventions, and CI integration patterns.

Activation

When this skill activates, output:

Test Writer: Generating test suite...

Then execute the protocol below.

Context Guard

ContextStatus
User says "write tests", "add tests", "test coverage"ACTIVE
User says "unit tests", "integration tests", "component tests", "e2e tests"ACTIVE
User says "mocking", "edge cases", "test this function"ACTIVE
User wants to refactor existing codeDORMANT: use Refactor Planner
User wants to change database schemaDORMANT: use Migration Planner

Common Mistakes

MistakeWhy It's Wrong
"Testing implementation, not behavior"Tests that break when you refactor internals are brittle. Test WHAT it does, not HOW.
"No edge cases"Happy path tests catch 20% of bugs. Boundaries, nulls, empty inputs, and error paths catch the rest.
"Mocking everything"Over-mocking creates tests that pass but don't catch real bugs. Mock boundaries, not internals.
"Test names like test1, test2"Names should describe behavior: "returns empty array when no items match filter". Self-documenting tests.
"No test isolation"Tests that depend on each other or shared state create flaky test suites that nobody trusts.

Protocol

Step 1: Gather Test Requirements

If the user hasn't provided details, ask:

  1. Target: what code needs tests? (function, class, module, API endpoint)
  2. Language/framework: what tech stack? (JS/TS + Jest/Vitest, Python + pytest, Go, etc.)
  3. Test level: unit, integration, e2e, or all three?
  4. Current coverage: any existing tests? What percentage?
  5. Priority: critical paths first, or comprehensive coverage?

Step 2: Analyze the Code Under Test

Before writing tests, understand the target:

Function/method analysis:

PropertyValue
Inputs[Parameters, types, optional/required]
Outputs[Return type, side effects, thrown exceptions]
Dependencies[External calls: DB, API, file system, other modules]
State changes[What mutates: database records, cache, global state]
Branching paths[Number of if/else/switch branches]
Error conditions[What can fail and how it's handled]

Dependency map:

[Target Function]
  ├── [Dependency 1]: mock? [Yes: external / No: pure]
  ├── [Dependency 2]: mock? [Yes: external / No: pure]
  └── [Dependency 3]: mock? [Yes: external / No: pure]

Mock decision rule:

  • Mock external boundaries: databases, APIs, file system, network, time
  • Don't mock pure functions, internal utilities, simple data transformations
  • Sometimes mock sibling modules (mock for unit tests, real for integration)

Step 3: Design Test Cases

Coverage strategy: identify all test scenarios:

Happy path tests:

#ScenarioInputExpected Output
1[Normal case with typical input][Input][Output]
2[Normal case with different valid input][Input][Output]

Edge case tests:

#CategoryScenarioInputExpected Output
1BoundariesMinimum valid value[Input][Output]
2BoundariesMaximum valid value[Input][Output]
3BoundariesExactly at limit[Input][Output]
4EmptyEmpty string / array / object"" / [] / {}[Output]
5Null/UndefinedNull inputnull[Output or error]
6Type coercionUnexpected type"123" vs 123[Output]
7Large inputVery large dataset[X items][Output / perf]
8UnicodeSpecial characters"café ñ 中文"[Output]
9ConcurrentRace condition scenario[Parallel calls][Consistent state]

Error path tests:

#Error ConditionInputExpected Behavior
1Invalid input[Bad input]Throws [ErrorType] with message
2Dependency failure[DB timeout]Returns fallback or propagates error
3Permission denied[Unauthorized]Returns 403 / throws AuthError
4Not found[Missing resource]Returns null or throws NotFoundError

Step 4: Write the Tests

Test file naming conventions:

FrameworkConventionExample
Jest / Vitest[name].test.ts or [name].spec.tsuserService.test.ts
pytesttest_[name].pytest_user_service.py
Go[name]_test.gouser_service_test.go
JUnit[Name]Test.javaUserServiceTest.java

Test naming conventions:

StylePatternExample
Behavior-drivenshould [expected] when [condition]should return empty array when no items match filter
Given-When-Thengiven [state] when [action] then [result]given expired token when authenticating then throws AuthError
Method-focused[method], [scenario], [expected]calculateTotal, with discount: applies percentage reduction

Test structure template (JavaScript/TypeScript):

typescript
describe('[ModuleName]', () => {
  // Setup shared across tests in this block
  let dependency: MockType;

  beforeEach(() => {
    dependency = createMock();
    // Reset state before each test
  });

  afterEach(() => {
    jest.restoreAllMocks();
  });

  describe('[methodName]', () => {
    // Happy path
    it('should [expected behavior] when [normal condition]', () => {
      // Arrange
      const input = { /* test data */ };
      dependency.method.mockResolvedValue(expectedData);

      // Act
      const result = targetMethod(input);

      // Assert
      expect(result).toEqual(expectedOutput);
    });

    // Edge case
    it('should [expected behavior] when [edge condition]', () => {
      // Arrange
      const input = { /* edge case data */ };

      // Act
      const result = targetMethod(input);

      // Assert
      expect(result).toEqual(edgeCaseOutput);
    });

    // Error path
    it('should throw [ErrorType] when [error condition]', () => {
      // Arrange
      const input = { /* invalid data */ };

      // Act & Assert
      expect(() => targetMethod(input)).toThrow(ErrorType);
    });
  });
});

Test structure template (Python):

python
import pytest
from unittest.mock import Mock, patch

class TestModuleName:
    """Tests for [ModuleName]."""

    def setup_method(self):
        """Reset state before each test."""
        self.dependency = Mock()

    # Happy path
    def test_method_returns_expected_when_normal_input(self):
        """Should [expected behavior] when [condition]."""
        # Arrange
        input_data = {"key": "value"}
        self.dependency.method.return_value = expected_data

        # Act
        result = target_method(input_data)

        # Assert
        assert result == expected_output

    # Edge case
    def test_method_handles_empty_input(self):
        """Should [expected behavior] when input is empty."""
        result = target_method([])
        assert result == []

    # Error path
    def test_method_raises_error_when_invalid_input(self):
        """Should raise ValueError when [condition]."""
        with pytest.raises(ValueError, match="expected message"):
            target_method(invalid_input)

Step 5: Mocking Strategy

Mock patterns by dependency type:

DependencyMock ApproachExample
DatabaseMock repository/ORM layerjest.spyOn(db, 'query').mockResolvedValue(rows)
HTTP APIMock HTTP client or use MSW/nocknock('https://api.example.com').get('/users').reply(200, data)
File systemMock fs module or use memfsjest.mock('fs/promises')
Time/DateFake timersjest.useFakeTimers(); jest.setSystemTime(new Date('2026-01-15'))
RandomSeed or mockjest.spyOn(Math, 'random').mockReturnValue(0.5)
EnvironmentSet/restore env varsprocess.env.NODE_ENV = 'test' in beforeEach
Third-party SDKMock the clientjest.mock('stripe', () => mockStripeClient)

Mock verification patterns:

typescript
// Verify a dependency was called correctly
expect(mockDb.query).toHaveBeenCalledWith(
  'SELECT * FROM users WHERE id = $1',
  [userId]
);

// Verify call count
expect(mockApi.fetch).toHaveBeenCalledTimes(1);

// Verify NOT called (important for caching tests)
expect(mockDb.query).not.toHaveBeenCalled();

// Verify call order (important for transaction tests)
const order = [];
mockDb.begin.mockImplementation(() => order.push('begin'));
mockDb.commit.mockImplementation(() => order.push('commit'));
// ... run test ...
expect(order).toEqual(['begin', 'commit']);

Step 6: Integration & E2E Tests

Integration test patterns:

typescript
describe('[Feature] Integration', () => {
  // Use real database (test instance), real logic, mock external APIs only
  let testDb: TestDatabase;

  beforeAll(async () => {
    testDb = await createTestDatabase();
    await testDb.migrate();
  });

  afterAll(async () => {
    await testDb.destroy();
  });

  beforeEach(async () => {
    await testDb.truncateAll(); // Clean state per test
  });

  it('should create user and send welcome email', async () => {
    // Arrange, mock only the email service (external boundary)
    const emailSpy = jest.spyOn(emailService, 'send').mockResolvedValue(true);

    // Act: use real DB, real validation, real business logic
    const user = await userService.register({
      email: 'test@example.com',
      name: 'Test User',
    });

    // Assert, verify real DB state + external call
    const dbUser = await testDb.query('SELECT * FROM users WHERE id = $1', [user.id]);
    expect(dbUser).toBeDefined();
    expect(emailSpy).toHaveBeenCalledWith(
      expect.objectContaining({ to: 'test@example.com' })
    );
  });
});

E2E test patterns (API):

typescript
describe('POST /api/users', () => {
  it('should create a user and return 201', async () => {
    const response = await request(app)
      .post('/api/users')
      .send({ email: 'test@example.com', name: 'Test User' })
      .expect(201);

    expect(response.body).toMatchObject({
      id: expect.any(String),
      email: 'test@example.com',
    });
  });

  it('should return 400 for invalid email', async () => {
    const response = await request(app)
      .post('/api/users')
      .send({ email: 'not-an-email', name: 'Test' })
      .expect(400);

    expect(response.body.error).toContain('email');
  });

  it('should return 409 for duplicate email', async () => {
    // Create first user
    await request(app).post('/api/users').send({ email: 'dup@example.com', name: 'First' });

    // Attempt duplicate
    const response = await request(app)
      .post('/api/users')
      .send({ email: 'dup@example.com', name: 'Second' })
      .expect(409);
  });
});

Step 7: Coverage & CI Integration

Coverage targets:

LevelTargetRationale
Critical paths (auth, payments, data writes)>90%Bugs here = revenue loss or security issues
Business logic (services, domain)>80%Core value: must work correctly
Utilities / helpers>70%Important but lower risk
UI components>60%Visual testing often complements
Overall project>75%Healthy baseline

CI configuration template (GitHub Actions):

yaml
name: Tests
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - run: npm ci
      - run: npm test -- --coverage

      - name: Check coverage thresholds
        run: |
          npx jest --coverage --coverageThreshold='{
            "global": {
              "branches": 75,
              "functions": 80,
              "lines": 80,
              "statements": 80
            }
          }'

Test runner configuration:

json
// jest.config.js / vitest.config.ts
{
  "collectCoverageFrom": [
    "src/**/*.{ts,tsx}",
    "!src/**/*.d.ts",
    "!src/**/index.ts",
    "!src/**/*.stories.tsx"
  ],
  "coverageThresholds": {
    "global": {
      "branches": 75,
      "functions": 80,
      "lines": 80,
      "statements": 80
    }
  }
}

Pre-commit test check:

bash
# Only run tests related to changed files (fast feedback)
npx jest --onlyChanged
# or
npx vitest --changed

Output Format

markdown
# Test Suite: [Target Module/Function]

## Analysis
- **Target:** [What's being tested]
- **Dependencies:** [X] total ([X] mocked, [X] real)
- **Branching paths:** [X]

## Test Cases
### Unit Tests ([X] tests)
[Test code from Step 4]

### Edge Cases ([X] tests)
[Edge case tests from Step 3]

### Error Cases ([X] tests)
[Error path tests from Step 3]

### Integration Tests ([X] tests)
[Integration tests from Step 6, if requested]

## Coverage Summary
- Lines: [X]%
- Branches: [X]%
- Functions: [X]%

## CI Integration
[CI config from Step 7, if requested]

Completion

Test Writer: Complete!

Target: [Module/function name]
Tests written: [X] total
  - Unit tests: [X]
  - Edge cases: [X]
  - Error cases: [X]
  - Integration tests: [X]
Mocked dependencies: [X]
Estimated coverage: [X]%

Next steps:
1. Run the test suite: [test command]
2. Check coverage report for uncovered branches
3. Add tests to CI pipeline (config provided above)
4. Add pre-commit hook to run related tests on save
5. Review and adjust coverage thresholds quarterly

Level History

  • Lv.1: Base: Code analysis template (inputs, outputs, dependencies, branches), 3-category test case design (happy path, edge cases, error paths), test templates for JS/TS and Python, 7 mock patterns by dependency type with verification, integration and E2E test patterns, coverage targets by code criticality, CI integration with GitHub Actions. (Origin: MemStack Pro v3.2, Mar 2026)

よくある質問

AIスキル「Memstack Development Test Writer」では何ができますか?

Use this skill when the user says 'write tests', 'add tests', 'test coverage', 'unit tests', 'integration tests', 'component tests', 'mocking', 'edge cases', or needs to generate tests with proper mocking and edge case coverage. Do NOT use for refactoring plans or database migrations.

TypingMindでMemstack Development Test Writerを使うメリットは何ですか?

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

TypingMindにMemstack Development Test Writerをインストールするにはどうすればよいですか?

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

Memstack Development Test Writerを使えるAIモデルはどれですか?

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

Memstack Development Test Writerで使えるAIモデルの数に制限はありますか?

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

AIスキル「Memstack Development Test Writer」は無料ですか?

はい。cwinvestmentsがMITライセンスのもとでGitHubに公開しています。ご利用のAIプロバイダーに支払うのは、使用したトークンの料金だけです。

AIスキルとは何ですか?

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

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

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

すべて見る

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

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