Build Fix

codewithmukesh/dotnet-claude-kit/skills/build-fix

作者 codewithmukesh23300897f4d1無授權條款754 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫2 個月前更新

Autonomous iteration loops for .NET: drive a broken build or failing test suite to green with bounded iterations, progress detection, and fail-safe guards that prevent infinite retries and wasted tokens. The build-fix loop (dotnet build, parse, categorize, fix, rebuild) is the primary flow; the test-fix loop is a first-class variant. Invoke when the build is broken, after a major refactor or dependency update, or when the user says "fix the build", "build is broken", "make it compile", "make the tests pass", "fix failing tests", "keep going until it works", "autonomous", "loop", "auto-fix", or "keep fixing".

AI 產生的概覽

以有界且具防護機制的迭代迴圈,讓損壞的 .NET 建置與失敗的測試套件恢復通過。

功能
此技能為 .NET 專案定義一套自主迭代迴圈:執行 dotnet build、解析編譯錯誤、依根本原因分類、套用針對性修正並重新建置,直到建置通過或觸發防護機制。測試修正變體執行 dotnet test --no-build,在變更前先診斷每個失敗,並禁止削弱斷言。它強制限定迭代次數、偵測進展、維持原子性,並在卡住、回歸、串聯失敗或嚴重錯誤時安全結束,每次迭代都回報進展。
適用情境
適用於 .NET 建置損壞且有多個編譯錯誤、程式碼變更或重構或 NuGet 升級後測試失敗,以及合併或 scaffolding 產生後尚未編譯通過的情況。也適用於使用者提出修正建置、讓它編譯通過或讓測試通過等要求。
執行需求
需要具備 dotnet CLI 的 .NET SDK(dotnet build、dotnet test),並能存取專案或方案。它引用選用的 MCP 工具進行診斷、符號查詢、參考分析與專案相依圖,並涉及相關技能與 dotnet-architect 代理。不附帶指令碼,僅為指示。

/build-fix

What

The kit's autonomous iteration-loop skill. It drives a broken dotnet build (or failing dotnet test) to green by looping: run, parse failures, categorize by root cause, apply targeted fixes, re-run. It repeats until green or a guard fires — the same way an experienced developer works through a wall of red, but with hard limits that stop it from thrashing.

This is not a single-pass fix. It handles cascading errors where fixing one issue reveals the next.

When

  • The build is broken and there are multiple compiler errors
  • Tests are failing after code changes or a build-fix pass
  • After a major refactor that touched type names, namespaces, or signatures
  • After updating NuGet packages (especially major version bumps)
  • After merging a branch with conflicts resolved but not compiled
  • After scaffolding or code generation that needs manual adjustments
  • User says: "fix the build", "make it compile", "make the tests pass", "keep going until it works", "keep fixing"

How

Loop Discipline (applies to every loop)

  1. Bounded iteration, always — Default max 5 iterations, hard cap 10 (user "keep going" extends by 3, never past 10). If 5 iterations cannot solve it, the problem needs human judgment, not a 6th identical attempt.
  2. Progress or exit — Each iteration must reduce the error/failure count. Same errors after a fix attempt = STUCK: stop, report, and re-plan with a different approach. Never retry the same fix that already failed.
  3. Categorize before fixing — Group errors by root cause and fix the highest-leverage first (one missing using can erase a dozen downstream errors).
  4. Transparency per iteration — Report what changed and why: Iteration 3/5: fixed CS0246 by adding using System.Text.Json, 2 remain. Never modify files silently.
  5. Atomicity — Each iteration leaves the codebase no worse than before. If iteration 3 fails, the code stays in iteration 2's state.

Primary Flow: Build-Fix Loop (max 5 iterations)

  1. Build — Run dotnet build, capture full error output

  2. Parse — Extract every error CS#### with file, line, and message

  3. Categorize — Group by root cause:

    CategoryCodesFix strategy
    Missing using/referenceCS0246, CS0234Add using, package, or project ref
    Type mismatchCS0029, CS1503Check expected type, cast or convert
    API changeCS0117, CS7036Check new signature, update call sites
    NullabilityCS8600–CS8604Add null check, ?. or ??
    Ambiguity / duplicateCS0104, CS0121, CS0111Qualify namespace, remove dupe
    Missing memberCS1061Check spelling, verify member exists
    Missing implementationCS0535Implement interface/abstract members
    Obsolete APICS0618Replace with recommended alternative
  4. Fix — Apply targeted fixes, root-cause/highest-leverage errors first

  5. Rebuild — Run dotnet build again, compare error count

  6. Evaluate — Zero errors: run dotnet test as a sanity check, report success. Fewer errors: continue. Same errors: STUCK — exit and re-plan. More errors: revert the iteration, report REGRESSION.

Variant: Test-Fix Loop (max 5; 3 if it follows a build-fix pass)

Same loop, same guards, with dotnet test --no-build as the runner and one critical extra step — diagnose before fixing:

  1. Read the test — understand the assertion and setup
  2. Read the production code — understand the actual behavior
  3. Decide where the bug lives: wrong expectation → fix the test; production bug → fix the code; incomplete setup → fix the setup; contract changed → update the test to match
  4. Never weaken an assertion to make a test pass. BAD: Assert.Equal(expected, actual) → Assert.NotNull(actual). GOOD: fix the production code so the original assertion passes.

Fail-Safe Guards (immediate exit)

  • STUCK — same errors/failures after a fix, or count oscillates (3 → 2 → 3): report what could not be fixed and what a human should check
  • REGRESSION — an iteration introduced more errors than it fixed: revert its changes, report
  • Cascading failures — fixing one error spawns 3+ new ones twice in a row: the approach is wrong, stop
  • Critical error — wrong SDK, missing project file, corrupted solution, or the test runner itself fails: human intervention needed, stop
  • User interruption — finish the current iteration, report progress, ask how to proceed

Other Loops

The same discipline — bounded iterations, progress detection, fail-safe guards — governs refactor passes (/de-sloppify: verify build + tests after each target, revert on failure) and scaffolding (/scaffold: generate, then run nested build-fix and test-fix loops). Nested loops get a smaller budget (parent 5 → nested 3), max nesting depth 2, total budget 15.

Invokes

TypeNamePurpose
Skillinstinct-systemCapture fix patterns in MEMORY.md
Agentdotnet-architectConsulted for architectural error patterns

MCP Tools Used

  • get_diagnostics — Compiler errors/warnings scoped to file or project
  • find_symbol — Locate moved or renamed types
  • find_references — Assess blast radius of a broken API change
  • get_project_graph — Dependency order for fixing reference errors

Example

User: /build-fix
Claude: Running dotnet build...  Found 12 errors across 4 files.
  Iteration 1/5:  - 6 errors: Missing namespace (CS0246) — adding using directives  - 3 errors: Type mismatch (CS1503) — updating method signatures  - 3 errors: Interface not implemented (CS0738) — package API changed
  Rebuilding... 3 errors remaining.
  Iteration 2/5:  - 3 errors: CS0738 after xunit.v3 upgrade    - IAsyncLifetime.InitializeAsync now returns ValueTask (was Task in v2),      and DisposeAsync comes from IAsyncDisposable    - Updating 3 test fixtures to the ValueTask signatures
  Rebuilding... 0 errors. Build is green.
  Running dotnet test... All 47 tests passed.  Added to Memory > Packages: "xunit.v3 IAsyncLifetime uses ValueTask signatures"

Related

  • /verify — Full verification pass (build + test + format + diagnostics)
  • /tdd — Red-green-refactor when building new features test-first
  • /de-sloppify — Clean up code quality issues after the build is green

來源與署名

來源:codewithmukesh/dotnet-claude-kit位於skills/build-fix提交2330089

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 codewithmukesh/dotnet-claude-kit 的技能

Wrap Up

codewithmukesh

在 session 結束時把已完成工作、待辦事項與經驗寫入交接檔案,並在 session 開始時重新載入。

Productivity & Workflow7542 個月前更新

Workflow Mastery

codewithmukesh

Claude Code workflow mastery for .NET developers. Covers parallel execution with git worktrees, plan mode strategy, verification loops, auto-formatting hooks, permission setup for dotnet CLI, prompting techniques, subagent patterns, and context discipline — token budget management, MCP-first navigation, lazy loading, and subagent isolation — all adapted for the .NET ecosystem. Load this skill when setting up Claude Code for a .NET project, optimizing workflows, running parallel sessions, when context is running low or sessions feel sluggish, when exploring a large codebase efficiently, or when the user mentions "productivity", "workflow", "parallel", "worktree", "plan mode", "permissions", "hooks", "10x", "setup Claude Code", "speed up development", "context", "tokens", "budget", "running out of context", "too many files", or "large codebase". Inspired by tips from Boris Cherny (creator of Claude Code) and the Anthropic team.

待分類7542 個月前更新

Vertical Slice

codewithmukesh

指導 .NET 開發者以垂直切片架構組織應用程式,涵蓋功能資料夾、端點分組與處理常式模式。

Software Development7542 個月前更新

Testing

codewithmukesh

Testing strategy for .NET 10 applications. Covers xUnit v3, WebApplicationFactory for integration tests, Testcontainers for real database testing, Verify for snapshot testing, and the AAA pattern. Load this skill when writing tests, setting up test infrastructure, reviewing test coverage, or when the user mentions "test", "xUnit", "WebApplicationFactory", "Testcontainers", "integration test", "unit test", "bUnit", "snapshot test", "Verify", "test coverage", "AAA pattern", "WireMock", or "FakeTimeProvider".

待分類7542 個月前更新

Tdd

codewithmukesh

Guided test-driven development workflow for .NET 10 using xUnit v3, WebApplicationFactory, Testcontainers, and Verify snapshots. Follows the strict red-green-refactor cycle. Use when: "TDD", "test-driven", "let's TDD this", "red green refactor", "write the test first", or when building a feature with clear acceptance criteria.

待分類7542 個月前更新

Spec

codewithmukesh

透過結構化提問,把模糊的功能想法轉化為雙方確認並持久化的規格文件。

Productivity & Workflow7542 個月前更新