Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计通过

csharp-codingcsharp 编码

Agent Skill

csharp-coding 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

630

周安装

26

GitHub Stars

1

下载量

206
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:csharp-coding(csharp 编码)
来源仓库:https://github.com/rcdailey/dotfiles
仓库路径:skills/csharp-coding
安装命令:
npx skills add https://github.com/rcdailey/dotfiles --skill csharp-coding
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/rcdailey/dotfiles --skill csharp-coding

简介

强制实施现代C#编码模式,所有条目均为硬性要求而非可选建议。

  • 适用于新项目开发与现有代码重构场景,需严格遵循语言版本约束条件。
  • 通过GitHub安装,自动检测TargetFramework确定可用C#特性子集。
  • 禁止使用低于最低版本要求的语法糖,优先采用records与init-only属性。
  • 提供LINQ查询优化、异步流处理与DI容器配置等企业级实践模板。

SKILL.md

C# Coding Skill

Mandatory patterns and idioms for writing modern C#. All items in this skill are requirements, not suggestions. Use for new code; opportunistically refactor existing code when revisiting.

Framework Detection

Before writing code, check TargetFramework in the project's csproj to determine the available C# language version. If the csproj has no TargetFramework, look for a Directory.Build.props (or other *.props file) that defines it; these files spread common properties across multiple projects. Only use features whose minimum version tag (e.g., C# 12+) is satisfied by the project. When a mandated feature is unavailable, fall back to the idiomatic alternative for that version.

Required Language Features

  • File-scoped namespaces: namespace MyApp.Core;
  • Primary constructors (C# 12+): class Service(IDep dep, ILogger logger)
  • Collection expressions (C# 12+): [], [item], [..spread]

- NEVER use new[], new List<T>(), Array.Empty<T>() - For type inference, prefer [new T {}, new T {}] over casts - Use T[] x = [...] only when simpler forms fail

  • Records for DTOs, init setters
  • Pattern matching: is not null, switch expressions, property patterns

- Property patterns: obj is Type {Prop: value} over obj is Type t && t.Prop == value - Recursive/nested: obj is Type {Outer: {Inner: value}} - Extended property pattern: obj is {Outer.Inner: value} (C# 10) - Empty property pattern: {} name matches non-null and binds (e.g., is Type {Prop: {} x})

  • Spread operator for collections (C# 12+): [..first,..second]
  • field keyword in properties (C# 14+): public string Name {get; set => field = value?? throw new ArgumentNullException();} = "";

- NEVER use explicit backing fields when field suffices

  • Extension members for methods, properties, operators (C# 14+); declared inside extension blocks within a top-level nongeneric static class: extension(IEnumerable<int> src) {public bool IsEmpty =>!src.Any();}

- NEVER use this parameter syntax for new extension methods; use extension blocks instead

  • Null-conditional assignment (C# 14+): obj?.Prop = value; over null checks wrapping assignment
  • Lambda modifiers without types (C# 14+): (text, out result) => int.TryParse(text, out result)

- NEVER add redundant parameter types when modifiers alone suffice

Required Idioms

Visibility

  • Use internal for implementation classes (CLI apps, service implementations)
  • Use public only for genuine external APIs
  • Concrete classes implementing public interfaces should be internal

Data Modeling

  • Records for data models
  • Favor immutability where reasonable
  • Use immutable collections: IReadOnlyCollection, IReadOnlyDictionary

JSON Serialization

  • Configure naming policy, converters, and style via JsonSerializerOptions (or source-generated JsonSerializerContext) so conventions apply uniformly
  • Check for existing options configuration before creating new instances
  • Reserve per-property attributes ([JsonPropertyName], etc.) for exceptions to the convention

UsedImplicitly Attribute

Mark runtime-used members (deserialization, reflection, DI):

  • [UsedImplicitly] - type instantiated implicitly (DI, empty marker records)
  • [UsedImplicitly(ImplicitUseKindFlags.Assign)] - properties set via deserialization
  • [UsedImplicitly(..., ImplicitUseTargetFlags.WithMembers)] - applies to type AND all members
  • Common for DTOs: [UsedImplicitly(ImplicitUseKindFlags.Assign, ImplicitUseTargetFlags.WithMembers)]

Warning Suppression

  • NEVER use #pragma warning disable
  • Use [SuppressMessage] with Justification on class/method level
  • Prefer class-level when multiple members need same suppression

LINQ

  • LINQ method chaining over loops
  • LINQ method syntax only; NEVER use query syntax (from/where/select keywords)

Method Calls

  • Named arguments for boolean literals: new Options(SendInfo: false, SendEmpty: true)
  • Named arguments for consecutive same-type parameters to clarify intent

Async

  • ValueTask for hot paths
  • CancellationToken everywhere (use ct for variable name)

Interfaces

  • Avoid interface pollution: not every service class must have an interface
  • Add interfaces when justified (testability, more than one implementation)

Local Functions

  • Local functions go after return/continue statements
  • Add explicit return; or continue; if needed to separate main logic from local function defs

Design Principles

Quality Gates

  • Zero warnings/analysis issues - treat warnings as errors
  • All code must pass static analysis before commit

Abstraction

  • Prefer polymorphism over enums when modeling behavior or extensibility
  • Propose enum vs polymorphism tradeoffs for discussion rather than defaulting to enums
  • Every abstraction must justify its existence with concrete current needs

Dependency Injection

  • MUST use DI for all dependencies; NEVER manually new service objects in production code
  • Concrete implementations get injected; tests can substitute
  • Search existing registrations before adding new ones

Comment Guidelines

Comments must earn their place by reducing cognitive load. When to comment:

  • LINQ chains (3+ operations): Brief comment stating transformation goal
  • Conditional blocks with non-obvious purpose: One-line comment (e.g., // Explicit: user specified)
  • Private methods: Block comment if name + parameters don't make purpose self-evident
  • Early returns/continues: Include reason if not obvious from context
  • Complex algorithms: Comment explaining approach at top, not line-by-line
  • Null-suppression operator (!): Every use MUST have an inline comment explaining why null is impossible at that point (e.g., // non-null: validated above, // non-null: dict always contains key after init). The comment documents the runtime guarantee so reviewers can verify it and future maintainers can detect if the invariant breaks.
  • General: Any code where a reader would pause and wonder "why?" or "what's happening here?"

NEVER:

  • XML doc comments (unless public API library)
  • Commented-out code
  • Restating what code literally does

Tooling

Formatting

  • CSharpier is the ONLY formatting tool
  • NEVER use dotnet format or other formatters
  • Run pre-commit hooks on all changed files

dotnet CLI

  • Use dotnet CLI for: adding/removing packages, adding projects to solution
  • Central package management via Directory.Packages.props - specify versions there, not in csproj
  • Avoid --no-build or --no-restore flags; dotnet test handles restore + build automatically
  • Quiet verbosity for build/test: dotnet build -v q, dotnet test -v q
  • For verbose debugging, pipe to file: dotnet test -v d 2>&1 > /tmp/test.log then search with rg

Project Structure

  • SLNX format preferred over traditional SLN
  • One Autofac/DI module per library to keep registration modular
  • Dotnet tools configured in .config/dotnet-tools.json
  • Keep source files flat in their project directory; create subdirectories only when file count makes navigation difficult

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

33.05%
按下载量换算68

Claude

30.8%
按下载量换算63

Cursor

18.07%
按下载量换算37

Gemini CLI

8.38%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills