dotnet-dev
Use when writing or explaining C# on .NET 10: the C# 14 features (field keyword, extension members, collection expressions), records against classes, nullable reference types, async and cancellation, DI lifetimes and the captive dependency, and renaming or finding callers through the language server instead of grep. Triggers: writing C#, record vs class, pattern matching, nullable reference types, async/await, CancellationToken, IAsyncEnumerable, DI lifetime, scoped vs singleton, IOptions, rename a C# method, write a test in xUnit, Fact or Theory. The xUnit test idiom lives here too: Fact, Theory, fixtures, run one test.
- License 许可
- GPL-3.0
- 最近更新
- 2026-11-13
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- dotnet-dev
- description
- Use when writing or explaining C# on .NET 10: the C# 14 features (field keyword, extension members, collection expressions), records against classes, nullable reference types, async and cancellation, DI lifetimes and the captive dependency, and renaming or finding callers through the language server instead of grep. Triggers: writing C#, record vs class, pattern matching, nullable reference types, async/await, CancellationToken, IAsyncEnumerable, DI lifetime, scoped vs singleton, IOptions, rename a C# method, write a test in xUnit, Fact or Theory. The xUnit test idiom lives here too: Fact, Theory, fixtures, run one test.
03 SKILL.md 正文
Writing C# code
C# written for this machine's .NET 10 SDK, where AnalysisMode is All under the strict profile
and every analyzer finding gates the build. This skill holds the choices the analyzers cannot make
and the features newer than what you were trained on most. It is not a language tutorial: what you
already write correctly is not repeated here.
Navigate by symbol, because grep finds spellings
Before renaming a method or changing a signature, list its callers through the language server, and
after editing a .cs file read the diagnostics. The compiler finds callers reached through an
interface or a generic constraint; a text search does not.
C# 14
The field keyword names a property's backing field, so a property with one rule needs no
hand-written field:
public int Value { get => field; set => field = value < 0 ? 0 : value; }
An extension block declares extension members, properties included, on one receiver:
static class Ext { extension(int[] source) { public int Total() => source.Sum(); } }
Collection expressions (List<string> names = [..first, ..second];) and list patterns
(args is ["--verbose", .. var rest]) replace the spelled-out forms.
Types
Use a record for a value, a class for an entity with identity, a readonly record struct for a
small hot-path value. Make a type immutable unless you can name what mutates it, and seal a class
unless it is built for inheritance, because the analyzers ask and an unsealed class is an extension
point you must keep working. required init properties stop an object being half-built without a
constructor per combination.
Match over a closed hierarchy with a switch expression, because a missing arm fails to compile
where an if chain stays silent.
Nullability is a contract
Nullable is on in both profiles and a warning is an error. Do not reach for !: make what you know
visible with a TryGet, or ArgumentNullException.ThrowIfNull(arg) at the boundary, because a
! moves the crash to run time.
Async
Take a CancellationToken last on every async method that can be waited on and pass it onward,
because a token that stops at one layer makes shutdown hang at the next. Never call .Result or
.Wait(): under thread-pool load that is the deadlock you cannot reproduce locally. Return
IAsyncEnumerable<T> for a stream the caller consumes as it arrives. Use
await foreach (var r in Task.WhenEach(tasks)) to take each result as it lands. A ValueTask is
awaited once.
Dependency injection
A singleton that takes a scoped dependency captures it forever, so the scoped object outlives its
scope. Keep scope validation on everywhere, not only in Development, because that is what catches
it at startup. Bind configuration to a typed options class with ValidateOnStart, so a missing
setting fails the deploy and not the first request. Inject an abstraction you own, never
IServiceProvider, because a service locator hides the dependency from the compiler and the reader.
Errors
Throw a specific exception naming the wrong value, and wrap with the inner exception when crossing a layer. Return a result type where failure is expected and the caller must handle it.
Tests in xUnit
One file per unit, named after it (OrderServiceTests.cs), test data built by a small factory that
shows only what matters. Whether a test is needed is software-testing.
[Fact]for one case;[Theory]with[InlineData]for one promise over many inputs, objects through[MemberData]on a static property.- The constructor is the setup and
IDisposable.Disposethe teardown, because xUnit builds a new instance per test, so state never leaks between tests. Expensive shared setup (a database container, a web host) goes inIClassFixture<T>, read-only. - An async test returns
Task, neverasync void, because anasync voidtest cannot fail.await Assert.ThrowsAsync<T>(...), and check the message or code too. - A hand-written fake over a mocking library; do not verify a call the result already proves.
- Mark slow or external tests
[Trait("Category", "Integration")]and exclude them by default:--filter "Category!=Integration". - Run one test:
dotnet test --filter "FullyQualifiedName~OrderServiceTests.Rejects".
Say it in the reply
Name the C# 14 or .NET 10 feature you chose when it replaces an older spelling, and for a rename or signature change say that you listed the callers through the language server. For a test file: file, count, and the command that runs it.
04 同仓库更多 Skills
worktrunk
Use when working with git worktrees or wt (worktrunk): creating, switching, merging or removing a branch workspace, configuring wt (project or personal config, workflow hooks around switch, commit and merge, commit-message generation, hook approvals), or a wt command that failed. Triggers: make a worktree for this branch, wt merge, wt remove, configure wt, .config/wt.toml, run tests before merge, install deps when a worktree is created, wt hook, wt switch does not cd, nastav wt, wt nefunguje.
web-ladder
Use when a task needs something the internet holds: look something up, search the web, find which page answers a question, read a page, check a library's current docs, a page that needs a browser or shows a captcha. Runs one research loop: searxng search, keywords, cases, search again up to three times, Context7 for a library, Tavily when the keywords will not come, one page in a browser, the person on a wall. Triggers: look this up, search the web, find out online, read this page, check the docs, the page is blocked, captcha, najdi na webu, otevri tu stranku. A multi-round question goes to the qsm-web:web-research agent; one tool's commands are its own skill (searxng, browserbox, opensrc).
searxng
Use when running a web search through the person's own SearXNG instance with qsm-web searxng: choosing a search profile or engines, the instance, time range or language, reading its JSON, a suspended engine. Triggers: search with searxng, qsm-web searxng, search profile, niche search, academic search, IT search, vyhledavaci profil, searxng is down, which engines. The research loop around it is the web-ladder skill.
opensrc
Use when the source code of an open-source library or repository is needed on disk to read: the docs are silent, the behaviour must be checked in code, the version the project pins. Runs qsm-web opensrc get with a package spec or a repository address. Triggers: get the source of this package, clone this library, read the library's code, qsm-web opensrc, stahni zdrojak knihovny. Library docs are the Context7 skill; the research loop is the web-ladder skill.
browserbox
Use when one page needs a real browser through qsm-web browserbox: content built by script, a page that blocks plain fetching, a captcha to solve or hand to the person, a scripted sequence of clicks, a login the person is present for. Triggers: open it in a browser, the page is empty without JavaScript, captcha, take over the browser, run these steps on the page, log in to this site, browserbox. When to reach for a browser at all is the web-ladder skill.
usage
Use when the user wants a review of how they use Claude Code, or setup hands over after a first install: review my Claude Code usage, audit my setup, what does my setup cost, where did my tokens go, clean up my Claude Code, usage report, zkontroluj moje pouzivani. One walkthrough of four stages (machine, work, habits, extensions), questions after each, then one plan. A question about one topic (which hooks are slow) goes to that topic's skill; this session's tokens alone is `/qsm-usage`.