AGENT SKILL

Vibe 测试编写与重构

write-vibe-tests

以适当的解耦方式编写或重构 Mistral Vibe 测试。当新增行为覆盖、测试端口/适配器、替换脆弱的 mock、创建 fake、在重构前添加特征化测试,或更改 tests/ 下涉及 vibe/core、vibe/app_server、vibe/acp、tools、config、sessions、skills、hooks、MCP 或 setup 的测试时使用。

适用职业测试工程师
License 许可
Apache-2.0
最近更新
2026-11-11
Stars
★ 5.4k
Forks
796

01 前言 Front Matter

name
write-vibe-tests
metadata
{ "display-name": "Write Vibe Tests", "default-prompt": "Use $write-vibe-tests to add or refactor Mistral Vibe tests around behavior and stable boundaries.", "short-description": "Write decoupled behavior tests for Vibe" }
description
Write or refactor Mistral Vibe tests with proper decoupling. Use when adding behavior coverage, testing ports/adapters, replacing brittle mocks, creating fakes, adding characterization tests before refactors, or changing tests under tests/ for vibe/core, vibe/app_server, vibe/acp, tools, config, sessions, skills, hooks, MCP, or setup.

03 SKILL.md 正文

Write Vibe Tests

Use this skill to make Vibe architecture testable, not just well-shaped. Tests should protect observable behavior while allowing internals to move.

Core Principle

Test behavior through stable boundaries. Do not couple tests to private methods, internal call choreography, or temporary structure.

If a refactor changes no observable behavior but breaks many tests, the tests are probably coupled to implementation details.

Vibe Test Boundaries

Code area Preferred test boundary
Core use cases and services Public function/class API, typed events, model outputs, persisted state
Tools Owning app-server capability contract, typed invocation/results, permissions and user-facing errors; BaseTool.invoke/run for retained BaseTool implementations
LLM/backend orchestration Native Unified Runtime through serialized app-server RPCs, with deterministic fake completion/discovery services
Config Pydantic model validation, layer merge outputs, migration results
Sessions Runtime session operations, durability/recovery and app-server projections; JSONL/metadata only for the supported read-only historical importer
Terminal UI (vibe/cli-rust) Rust unit tests for pure logic, client-e2e scenarios and goldens for rendering and interaction (see vibe/cli-rust/AGENTS.md)
ACP ACP session updates and protocol-facing content, not core internals

Prefer Fakes Over Mocks

Prefer in-memory implementations and fake adapters that implement real contracts.

  • Put reusable test doubles in tests/stubs/ and name them Fake*.
  • Make fakes small and behavior-oriented.
  • Mock only at hard process, network, time, or third-party boundaries when a fake would be more complex than the behavior under test.
  • Avoid assertions like "method X was called with Y" unless the call itself is the observable contract.

Legacy Or Refactor Workflow

When code is hard to test:

  1. Find the smallest seam: function boundary, constructor dependency, protocol/port, wrapper, composition root, feature flag, or module boundary.
  2. Add characterization tests through the nearest public entry point.
  3. Capture current observable behavior, even if awkward.
  4. Refactor behind the seam in small steps.
  5. Replace broad characterization checks with clearer behavior/spec tests as the design improves.

Prefer "make it testable" refactors first: isolate I/O, extract pure functions, introduce ports/adapters where useful, or move construction out of business logic.

Test Shape

  • Python stack: pytest + pytest-asyncio + respx.
  • Use descriptive test names; do not add test docstrings. Pytest displays docstrings instead of node IDs when present, which hurts.
  • Arrange, act, and assert clearly, but optimize for readability over ceremony.
  • Keep tests deterministic, fast, and explicit about failure.
  • Never let a test depend on wall-clock timing (sleeps, pauses, time windows, mtime ticks). Timing-dependent tests flake on loaded CI runners.
  • Use autouse fixtures from tests/conftest.py (config_dir, tmp_working_directory) for config/home/working-directory isolation.
  • Mark async tests with @pytest.mark.asyncio.
  • Mock outbound HTTP with respx.
  • Use the narrowest relevant test first, then broaden when shared contracts are touched.
  • Tests are exempt from the ANN and PLR ruff rules (see per-file-ignores).
  • Changes to managed shell tools, managed shell backends, shell prompts, or shell dependencies require focused POSIX/common validation and passing Windows shell CI. If Windows shell CI is unavailable, the PR notes must include manual native Windows commands and results.
  • After app-server session behavior, backend adapters, or shared contract-fixture changes, run the Unified backend contract suite (uv run pytest tests/app_server/backend_contract) and the affected app-server/ACP tests. Preserve original snapshot scenarios when adapting fixtures to the Unified Runtime.

Avoid

  • Testing private methods as the primary coverage for behavior.
  • Asserting intermediate internal state when user-visible output, emitted events, files, or return values can be asserted.
  • Building mocks that mirror the implementation.
  • Adding abstractions only to satisfy a test.
  • Writing tests that require a specific internal file split or call order when the domain behavior is unchanged.

Verification

After Python test/code changes, run:

uv run ruff format .
uv run ruff check --fix .

Then run the targeted tests:

uv run pytest <test-path-or-node-id>

Run uv run pyright when signatures, models, protocols, or shared contracts changed.

04 同仓库更多 Skills

mistralai
mistralai/mistral-vibe

import

Import the user's setup from other coding CLIs (Claude Code, Codex, OpenCode) into Vibe — instructions, skills, subagents, commands, hooks, MCP servers, permissions, and plugins. Load when the user wants to switch to Vibe, import or reuse another CLI's configuration, or asks whether a file from another CLI works in Vibe.

★ 5.4k
mistralai
mistralai/mistral-vibe

Git 工作树管理

worktree

在 $VIBE_HOME/worktrees 下创建、复用和清理 git worktrees。当用户想要在隔离的 git worktree 中工作、为某个任务创建 worktree,或列出/删除现有 worktrees 时使用。

软件开发工程师代码仓库协作管理
★ 5.4k
mistralai
mistralai/mistral-vibe

Vibe CLI 权威参考

vibe

Mistral Vibe 的权威参考——你(模型)正运行于其中的 CLI agent。 在以下情况加载本技能: - 用户询问任何关于 Vibe 本身的问题,即使是间接称呼(“这个 CLI”“这个工具”“你”); - 想要更改、检查或重置其设置; - 询问 agent 为何采取或未采取某行动; - 询问如何让 CLI 做 X、X 位于何处,或某个 flag/command/setting 的作用; - 询问关于你自身行为的任何元问题; - 不确定某个命令、flag、环境变量或文件是否在范围内——本技能即为权威来源。 范围:`~/.vibe/` 下的配置及项目本地的 `.vibe/`;`VIBE_*` 和 `LOG_*` 环境变量;模型与提供者;agents 与 subagents;skills;工具及其权限模型;所有斜杠命令和 CLI flag;hooks;MCP servers;connectors;plugins;受信任文件夹;`@` 文件引用;日志;主题;语音。

AI 工程师开发环境与工具链管理
★ 5.4k
mistralai
mistralai/mistral-vibe

Vibe 技能创建与管理

skill-creator

在创建、更新或删除 Vibe 技能之前,或当你计划添加或修改 skills 目录下的 SKILL.md 文件时,加载本技能。它讲解 Vibe 的 SKILL.md frontmatter、发现顺序、支持文件以及权限流程。

AI 工程师插件与技能管理
★ 5.4k
mistralai
mistralai/mistral-vibe

Vibe 插件创建

create-plugin

创建 Vibe 插件包——采用 Agent Plugins 1.0 格式,并可选地包含针对 skills、MCP servers、hooks、knowledge、agents、libraries 和 connectors 的 Vibe 扩展。当用户想要为 Mistral Vibe 创建、搭建或编写插件时使用。

AI 工程师插件与技能管理
★ 5.4k
mistralai
mistralai/mistral-vibe

提示词

prompts

暂无简介

AI 工程师提示词工程与优化
★ 5.4k