dsh-pre-push-checks
deepseek-ai/deepseek-harness · Agent Skill
自動選擇最少的測試集來驗證推送前或同步後的變更,避免執行整個儲存庫。
前往安裝 ↓總覽
| 發布者 | |
|---|---|
| 儲存庫 | deepseek-ai/deepseek-harness ↗ |
| 技能資料夾 | dsh-ci-test-reliability |
| 星 | 221,017 |
| 附帶檔案 | 1 |
| 授權 | MIT |
| 最近更新 | 2026年9月9日 |
| 連結 | 技能原始碼 ↗ · 儲存庫 ↗ |
Mozgi 檢查
我們在技能檔案中發現的內容。詳細資訊需訂閱。
安裝
技能就是一個含 SKILL.md 的資料夾。選擇你的代理,在專案根目錄的終端機(macOS、Linux 或 Windows 的 Git Bash)執行指令。
把提示貼到 Claude、Codex 或其他助理:它會自行檢查並安裝技能。
Install the “dsh-pre-push-checks” skill from mozgi.io (https://mozgi.io/skills/dsh-pre-push-checks/) for me. 1. Download the archive: https://mozgi.io/skills/dsh-pre-push-checks/download If it fails, take the skill folder from the source: https://github.com/deepseek-ai/deepseek-harness/tree/master/.agents/skills/dsh-ci-test-reliability 2. Read SKILL.md and the other files. Check the skill is safe: no hidden commands, no sending data elsewhere, no scripts doing something other than described. If anything looks suspicious, stop and tell me. 3. Put the “dsh-pre-push-checks” folder into your agent's skills folder: .claude/skills/ for Claude Code, .agents/skills/ for Codex, .cursor/skills/ for Cursor, .gemini/skills/ for Gemini CLI. Inside the project if we are in one, otherwise in the home folder (~/.claude/skills/ etc.). 4. Make sure <skills folder>/dsh-pre-push-checks/SKILL.md exists. 5. Briefly tell me what this skill does and offer to try it on my task. If you cannot do a step yourself, tell me what to click or type.
git clone --depth 1 --branch master https://github.com/deepseek-ai/deepseek-harness.git /tmp/deepseek-harness mkdir -p .claude/skills cp -r /tmp/deepseek-harness/.agents/skills/dsh-ci-test-reliability .claude/skills/dsh-ci-test-reliability
重新啟動 Claude Code — 技能就會出現在清單中,手動呼叫:/dsh-pre-push-checks。要套用到所有專案,請放在 ~/.claude/skills。
git clone --depth 1 --branch master https://github.com/deepseek-ai/deepseek-harness.git /tmp/deepseek-harness mkdir -p .agents/skills cp -r /tmp/deepseek-harness/.agents/skills/dsh-ci-test-reliability .agents/skills/dsh-ci-test-reliability
Codex 會從目前資料夾往上到儲存庫根目錄,在 .agents/skills 中尋找技能;用 /skills 或 $dsh-pre-push-checks 呼叫。所有專案:~/.agents/skills。
git clone --depth 1 --branch master https://github.com/deepseek-ai/deepseek-harness.git /tmp/deepseek-harness mkdir -p .cursor/skills cp -r /tmp/deepseek-harness/.agents/skills/dsh-ci-test-reliability .cursor/skills/dsh-ci-test-reliability
Cursor 啟動時會載入技能;在 Agent 聊天輸入「/」呼叫。Cursor 也會讀取 .claude/skills 與 .agents/skills。所有專案:~/.cursor/skills。
git clone --depth 1 --branch master https://github.com/deepseek-ai/deepseek-harness.git /tmp/deepseek-harness mkdir -p .gemini/skills cp -r /tmp/deepseek-harness/.agents/skills/dsh-ci-test-reliability .gemini/skills/dsh-ci-test-reliability
任務符合時,Gemini CLI 會提議啟用技能,由你確認。所有專案:~/.gemini/skills。
安裝前請先檢視 SKILL.md 與相關檔案。點擊檔案即可預覽。
SKILL.md 內容
作者原文 · 唯讀Reliable DSH CI tests
Build tests that remain correct under the repository's real CI topology, not only when run alone on a quiet workstation. This skill owns isolation and reliability decisions; it does not replace the repository's test-tier policy or select every command for a push.
Read the owning rules
- Use the testing policy to select unit, coverage, expected-output, snapshot, browser, or real-API evidence.
- Use the defensive patterns for lifecycle, subprocess, cancellation, and teardown behavior.
- Read the active Vitest config and GitHub workflow when their worker or job topology affects the test.
- For recorded-session scenarios, also follow the snapshot instructions.
- Use dsh-pre-push-checks after the test design is sound to select outgoing validation.
Model the execution topology
Assume these layers can overlap unless the active configuration proves otherwise:
1. Tests in one Vitest file.
2. Separate Vitest files or worker processes.
3. Independent Vitest or repository-gate processes in one job.
4. Different Actions jobs whose runners share one host.
Process isolation does not isolate host ports, predictable filesystem paths, external services, databases, sockets, or inherited child processes. For every acquired resource, identify its owner, atomic allocation mechanism, observable readiness signal, registered cleanup, and quiescent completion signal.
Do not serialize an entire suite merely because one fixture lacks isolation. Narrow the exclusive scope or change the resource allocation first. A sequential Vitest block cannot protect a host resource from another file, process, job, or runner.
Allocate resources atomically
Use the resource owner's allocator instead of checking availability and claiming it later.
- Network fixtures bind loopback with
listen(0)and read the assigned address only after the server reports that it is listening. Never scan for a free port and bind it later. - Create private per-test temporary roots with
mkdtemp; do not acquire predictable shared paths. - Give shared databases, sockets, sessions, and output locations unique per-test namespaces.
- Use exclusive creation where a path must not already exist.
- Keep stable recorded identifiers separate from ephemeral transport addresses. Translate inside the fixture instead of forcing the live resource to use the recorded value.
Literal paths and URLs used only as parser inputs or expected values are not acquired resources. Do not rewrite them merely because they look fixed.
Contain process-global state
Treat process.env, cwd, fake timers, locale and timezone, module mocks, registries, console hooks, globalThis, and global fetch interception as exclusive mutable resources.
Prefer an injected dependency or instance-local adapter. When mutation is required:
- capture whether the original value was absent or present;
- restore that exact state;
- register restoration immediately;
- use
try/finallyaround the smallest mutation scope; - keep an
afterEachfallback when failure before the localfinallyis plausible; - intercept the narrowest exact request or call that the fixture owns.
Respect platform-owned semantics
CI runs the same suite on Windows and on POSIX hosts, and a value the operating system owns does not always come back the way a test wrote it.
- Writing a value back is safe only when the assertion tolerates the write-back failing. Restoring a file's
mtimeto prove that a fingerprint invalidates anyway holds everywhere; restoring it to prove that a record stays valid assumes a lossless round trip, which NTFS's 100-nanosecond ticks do not give a fractional millisecond. When the assertion depends on the restoration, take the expected value from a fresh read rather than from the remembered one. - Windows matches environment variable names case-insensitively, so a fixture seeding
http_proxyandHTTP_PROXYas separate keys holds one entry there. - Windows releases file handles asynchronously, so a rename or removal that completes at once on a POSIX host needs a bounded retry sized to the observed contention.
- Windows has no POSIX permission or signal semantics. A case that depends on them takes an explicit platform skip naming the reason, rather than an assertion weakened everywhere.
Prefer an observation that holds on every platform. When a case genuinely cannot, exclude it on that platform explicitly.
Budget timeouts against the lane
A describe or case timeout overrides the runner's --testTimeout instead of yielding to it, so a value below the lane's budget lowers what CI already granted — and the same literal reads as a widening on a host whose default is smaller. A suite bound by process creation takes the lane budget; a tighter value carries the reason it is tighter.
Raise the hook budget with the test budget. Setup and teardown pay the same contention, so lifting only the case budget moves a contended failure into afterEach.
Where a timeout is the subject, keep the outer wait far larger than the timeout under test. A case proving that a 20 ms deadline fires must not race the harness's own wait, or load decides which deadline reports first.
Synchronize on state
A fixed sleep is not evidence that setup completed or cleanup settled.
- Wait for an explicit readiness event, handshake, state transition, owned promise, or externally observable condition.
- Use deferred promises or barriers to place a race at a deterministic point and prove the relevant operations overlap.
- Use a timeout only to bound a wait, never as the condition that makes the assertion correct.
- Do not assert scheduler-dependent ordering unless that ordering is the product behavior under test.
- When time itself is the subject, inject or fake the clock and always restore real timers.
Dispose to quiescence
Register cleanup immediately after acquisition so assertion failures also release the resource. Cleanup stops new callbacks or requests, detaches listeners, restores global hooks, terminates owned work, and awaits child exit, server close, worker termination, or the equivalent completion signal.
Calling abort(), close(), or kill() without awaiting the owned completion signal is incomplete teardown. When late completion is possible, prove that disposal prevents it from mutating another test.
Prove the intended regression
- Observe an ordinary regression fail before the fix when practical.
- For a new static or corpus guard, temporarily introduce the rejected case and observe the intended failure.
- For a race, use barriers to prove overlap; repeated execution alone is not a race test.
- For ports, sockets, shared paths, subprocesses, or other host resources, run independent test processes concurrently when cross-process isolation is part of the fix.
- Where a fixture spawns with its own deadline, assert that no signal or timeout ended the child before asserting its exit status, so a killed child reports as a timeout instead of as a status mismatch.
- Verify external state, events, files, logs, exits, or disposal instead of trusting the component's self-report.
Stress runs supplement a deterministic regression; they do not replace one.
Reject flake-masking fixes
Do not present these as root-cause fixes for deterministic local tests:
- increasing a timeout without identifying the awaited state;
- adding retries;
- making all files serial;
- swallowing an error or unhandled rejection;
- weakening an assertion;
- normalizing away unstable behavior;
- adding a sleep before cleanup or assertion.
Retries remain valid for documented transient external-provider tests under the real-API policy. Keep that exception at the external boundary.
Restoring a budget is not masking. Raising a suite to the lane budget it already had, or sizing a bounded retry to the contention actually measured on the runner, names the awaited work and returns what the lane granted; neither invents headroom around an unexamined wait.
Diagnose existing flakes
For an existing probabilistic CI failure, read the CI flake diagnosis workflow ↗. A diagnosis-only request remains read-only: report the cause and evidence unless the user also asks for a fix.
Validate and report
Run the smallest focused regression for the affected behavior. Add topology-specific evidence only when the change owns that risk:
- global mutation needs restoration evidence;
- lifecycle or subprocess work needs quiescent teardown evidence;
- ports, sockets, or shared paths need concurrent independent-process evidence;
- a new guard needs a negative control.
Before a push, use dsh-pre-push-checks. Report exact commands and observed results; do not describe retries, skipped tests, or pending CI as passing.
常見問題
dsh-pre-push-checks 技能有什麼用途?
自動選擇最少的測試集來驗證推送前或同步後的變更,避免執行整個儲存庫。
如何安裝 dsh-pre-push-checks?
打開本頁的「安裝」區塊並選擇你的代理 — Claude Code、Codex、Cursor 或 Gemini CLI:那裡有把技能資料夾複製到正確位置的現成指令。也可以複製「透過助理」分頁中的提示,讓助理自行檢查並安裝技能。
dsh-pre-push-checks 適用哪些 AI 模型?
技能是純 Markdown 指示(Agent Skills 格式),因此 dsh-pre-push-checks 適用任何讀取 SKILL.md 的代理:Claude Code、Codex、Cursor、Gemini CLI、GitHub Copilot、OpenCode 等。只有在任務符合技能描述時,模型才會載入指示。
dsh-pre-push-checks 是免費的嗎?
此技能由 deepseek-ai 公開發布,採用 MIT 授權。技能本身免費 — 你只需向 AI 供應商支付實際使用的 token 費用。
安裝技能安全嗎?
技能是代理會遵循的指示,安裝前請閱讀 SKILL.md 及相關檔案。技能資料夾中的腳本只有在代理執行時才會運行 — 留意它的動作,不要授予多餘權限。
技能和 MCP 伺服器或外掛有何不同?
MCP 伺服器或外掛為模型提供新工具 — 會執行並回傳結果的程式碼。技能提供的是知識與流程:如何處理任務、要遵循哪些步驟、好的成果長什麼樣子。它不需要伺服器或 API 金鑰。