go-testing
できること
このスキルは、Goのプログラミング言語でテストを書いたりレビューしたりするとき、AIを導きます。ターミナルのインターフェースのテストを含め、集中して信頼できるテストがほしいGo開発者向けです。
使う場面
- ✓入力のケースが多いGoの関数のテストを書くとき。
- ✓Bubbleteaで作られたターミナルのユーザーインターフェースをテストしているとき。
- ✓ゴールデンファイルのテストや、ファイルシステムに触れるテストが必要なとき。
スキルのリンク
https://github.com/Gentleman-Programming/gentle-ai/blob/main/internal/assets/skills/go-testing/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“このパーサーの表駆動のGoテストを、エラーのケースも含めて書いてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
スキルは、対象に合わせてテストのパターンを選びます。関数には表駆動のテスト、ターミナルのインターフェースには直接のモデルの更新を使います。テストを決定的に保ち、短いモードでは遅い外部テストを飛ばします。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Activation Contract
Load this skill when writing or reviewing Go tests, adding coverage, testing Bubbletea/TUI flows, using teatest, or updating golden files.
Hard Rules
- Prefer table-driven tests for multiple cases; use
t.Run(tt.name, ...). - Test behavior and state transitions, not implementation trivia.
- Use
t.TempDir()for filesystem tests; never rely on a real home directory. - Keep integration tests skippable with
testing.Short()when they run external commands or slow flows. - For Bubbletea, test
Model.Update()directly for state changes; useteatestonly for interactive flows. - Golden files must be deterministic; update only through the repo's
-updatepath and rerun tests without-update. - Use small mocks/interfaces around system or command execution boundaries.
Decision Gates
| Target | Test pattern |
|---|---|
| Pure function or parser | Table-driven unit test. |
| Error behavior | Explicit success and failure cases. |
| File operations | t.TempDir() plus focused assertions. |
| TUI state transition | Direct Model.Update() call with tea.Msg. |
| Full TUI interaction | teatest.NewTestModel(). |
| Rendered output | Golden file test. |
| Real external command | Integration test; skip in -short. |
Execution Steps
- Identify behavior under test and the smallest public boundary that proves it.
- Choose the test pattern from the decision gate.
- Name cases by scenario, not input mechanics.
- Assert outputs, errors, state, and side effects explicitly.
- Run the narrow package test first, then the relevant broader suite.
- For golden updates: run with
-update, inspect diff, then rerun without-update.
Output Contract
Report test files changed, scenarios covered, commands executed, golden files updated, and any skipped integration scope.
References
- references/examples.md — compact table-driven, Bubbletea, teatest, golden, and command examples.
よくある質問
ゴールデンファイルとは何ですか?
テストが比較する、保存された期待される出力です。スキルは、それが決定的であることを求めます。
ターミナルのインターフェースはどうテストしますか?
状態の変化を直接テストし、完全な対話の流れにだけteatestを使います。
テストで実際のホームフォルダを使いますか?
いいえ。スキルは一時フォルダを使い、実際のホームディレクトリには決して頼らないよう述べています。
詳細
作者による元の説明
Trigger: Go tests, go test coverage, Bubbletea teatest, golden files. Apply focused Go testing patterns.
人気
- GitHubのスター
- 8.2k
- ランキング
- #12551
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
branch-pr
8.2k一般的なテンプレートではなく、送り先のプロジェクト自身の貢献のルールに従うブランチとプルリクエストを準備するよう、エージェントを支援します。
chained-pr
8.2k400行を超える大きな変更を、それぞれ単独で成立する、小さくレビューしやすいプルリクエストの連鎖に分割するよう、エージェントを支援します。
cognitive-doc-design
8.2k答えを先に示し、詳細をまとめることで、読み飛ばしやすく覚えやすいガイド、README、レビューを書くよう、エージェントに教えます。
comment-writer
8.2kプルリクエスト、レビュー、Issueへの返信、チームのチャットのメッセージのために、短く、温かく、率直なコメントを書くよう、エージェントを支援します。
似ているスキル
test-driven-development
311k機能や修正を作る前に、まず失敗するテストを書き、それが失敗するのを確認してから、合格させる最小のコードを書くようエージェントに教えます。
verification-before-completion
311kタスク、修正、ビルドが完了した、または合格したと主張する前に、実際のチェックを実行し、その出力を読むようエージェントに教えます。
migrate-to-shoehorn
310kテストファイル内の危険な型キャストを、shoehornライブラリに置き換え、テストが部分的なデータを使いつつ型チェックを通るようにします。