add-diag-instrumentation

add-diag-instrumentation is a skill for Claude Code, Codex from grasscaograss/AwesomeWeldoneSkills. It costs 213 tokens per session (2,826 once invoked), scanned A, original, Apache-2.0.

A .NET instrumentation workflow that adds structured EventSource events and configures automatic crash dumps with dotnet-monitor. EventSource records selected runtime events that can be collected later for diagnosis.

In plain words
What is it for?
Use it for dynamic diagnostics, performance tracing, recurring issue investigation, or saving a dump after a crash; a dump is a snapshot of a running program's memory.
Why use it?
It supports long-term observation of rare or hard-to-reproduce problems without repeatedly adding text logs or releasing a new build.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it for dynamic diagnostics, performance tracing, recurring issue investigation, or saving a dump after a crash; a dump is a snapshot of a running program's memory.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add grasscaograss/AwesomeWeldoneSkills --skill add-diag-instrumentation
Clone the repo
git clone --depth 1 https://github.com/grasscaograss/AwesomeWeldoneSkills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for add-diag-instrumentation

README.md
[![agentmods](https://agentmods.dev/badge/skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation/github.svg)](https://agentmods.dev/skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation)
Your own site
<a href="https://agentmods.dev/skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation"><img src="https://agentmods.dev/badge/skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for add-diag-instrumentation

Your own site · 80×15
<a href="https://agentmods.dev/skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation"><img src="https://agentmods.dev/badge/skills/grasscaograss/awesomeweldoneskills/add-diag-instrumentation.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 213 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,826 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00213 $0.02826
Opus 5 $0.00106 $0.01413
Sonnet 5 $0.00043 $0.00565
Haiku 4.5 $0.00021 $0.00283

Measured 11d ago against content hash 03c89948115c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

add-diag-instrumentation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

add-diag-instrumentation/SKILL.md · 149 lines

How it starts

The opening of the file, as written. The whole thing — 149 lines — stays where its author put it; the contents beside it link to each section on GitHub.

诊断埋点(EventSource + dotnet-monitor)

为 .NET 代码添加运行时动态诊断能力。与 add-diag-logs(注入 ILogger 文本日志,每次要改源码发版)互补:本 skill 埋的是 EventSource 结构化事件,编译期一次性完成,运行时默认零开销,出问题时用 dotnet-trace/dotnet-monitor 远程动态开启抓取,无需重新发版。

详细的事件设计原则、参数约束、weldone 已有 EventSource 清单,见 references/instrumentation-guide.md埋点前必读。

核心判断:先决定用哪种诊断

收到埋点请求后,先判断问题形态,决定工具,不要无脑加 EventSource:

问题形态 工具 本 skill 是否适用
一次性 bug,加几条日志就能定位 add-diag-logs(ILogger) ❌ 用 add-diag-logs,本 skill 杀鸡用牛刀
偶发问题,需长期反复收集数据 EventSource(本 skill) ✅ 正是为此设计
需要全流程性能剖析(哪一步慢) dotnet-trace + EventSource ✅ 两者配合
需要看某个对象全部字段值(含未埋点的) dotnet-dump ⚠️ 不需要埋点,直接抓 dump
崩溃后需自动留现场 dotnet-monitor Collection Rule ✅ 用本 skill 的 dump 配置流程

决策原则:能用 ILogger 解决的别上 EventSource;偶发/难复现/需长期观测的才上 EventSource;要看未埋点对象的字段值用 dump。

工作流程

步骤一:分析埋点目标

  1. 读取用户指定的方法/流程源码,理解:输入参数、输出、内部关键分支、外部调用、循环
  2. 识别"出问题时最想知道什么"——这是事件参数的设计依据(见下文"参数设计")
  3. 检查目标类是否已有 EventSource 引用(grep EventSource in 目标文件及同目录)

步骤二:选择或创建 EventSource

判断目标代码所属业务域,匹配现有 EventSource 或新建:

  1. references/instrumentation-guide.md 的「weldone EventSource 清单」章节,看目标域是否已有 EventSource
  2. 已有 → 在其中追加 [Event(id)] 方法,id 接续现有最大值 +1
  3. 没有 → 新建 EventSource 文件,命名用业务域Robim-WeldPlanning),不用类名/方法名
    • 放在目标代码所在工程下的 Diagnostics/ 或根目录
    • [EventSource(Name = "Robim-{业务域}")]

命名约束(混淆兼容):EventSource 的 Name 是字符串常量,不受代码混淆影响。务必用业务语义命名(Robim-WeldPlanningRobim-RobotControlRobim-VisionPositioning),这样混淆后照样能 dotnet-trace --providers Robim-WeldPlanning 开启。

步骤三:设计事件参数(最关键)

EventSource 的价值在于带变量值,不是只发"进入/离开"信号。光有调用关系无法定位——必须带上问题定位所需的输入输出值。详细规则见 references/instrumentation-guide.md 的「参数设计」章节,核心要点:

  1. WriteEvent 参数类型硬限制:只接受 string/int/long/float/double/bool/byte + 这些类型的一维数组。不能传自定义类、struct(含 Matrix4x4)、接口、字典。复杂对象必须拆解为基础类型。
  2. 位姿/矩阵拆解:weldone 大量用 Matrix4x4Pose。埋点时拆成 posX,posY,posZ + 旋转矩阵 9 个分量(或四元数 4 个分量),别整体传。
  3. 集合取摘要List<T>Count + 前几个关键元素(如前 3 个焊缝的 seamIndex),别传整个集合。
  4. 每类事件至少带:业务 ID(workpieceId/seamIndex,用于关联同一流程)、success/durationMs(用于判断是否异常)。

Read the full file on GitHub · 149 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 149 lines · 213 tokens per session scan A 03c89948115c

Subscribe to this mod's changes

add-diag-instrumentation is a skill published in the GitHub repository grasscaograss/AwesomeWeldoneSkills (2 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 213 tokens to every session and 2,826 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

dotnet-reverse

A guide for analyzing compiled .NET and C# programs, including managed Windows executables and libraries. Reverse engineering means studying compiled software to understand how it works, and decompiling turns it back into readable approximate source code.

zhaoxuya520/reverse-skill · 144 tokens

check-bin-obj-clash

Detects MSBuild projects with conflicting OutputPath or IntermediateOutputPath. USE FOR: builds failing with 'Cannot create a file when that file already exists', 'The process cannot access the file because it is being used by another process', intermittent build failures that succeed on retry, or missing/overwritten…

dotnet/skills · 160 tokens

build-perf-diagnostics

Diagnose MSBuild build performance bottlenecks using binary log analysis. USE FOR: identifying why builds are slow by analyzing binlog performance summaries, detecting ResolveAssemblyReference (RAR) taking >5s, Roslyn analyzers consuming >30% of Csc time, single targets dominating >50% of build time, node utilization…

dotnet/skills · 160 tokens

dump-collect

Configure and collect crash dumps for modern .NET applications. USE FOR: enabling automatic crash dumps for CoreCLR or NativeAOT, capturing dumps from running .NET processes, setting up dump collection in Docker or Kubernetes, using dotnet-dump collect or createdump. DO NOT USE FOR: analyzing or debugging dumps…

dotnet/skills · 96 tokens

binlog-generation

Generate MSBuild binary logs (binlogs) for build diagnostics and analysis. USE FOR: adding /bl:{} to any dotnet build, test, pack, publish, or restore command to capture a full build execution trace, prerequisite for binlog-failure-analysis and build-perf-diagnostics skills, enabling post-build investigation of errors…

dotnet/skills · 133 tokens

binlog-failure-analysis

Analyze MSBuild binary logs to diagnose build failures. USE FOR: build errors that are unclear from console output, diagnosing cascading failures across multi-project builds, tracing MSBuild target execution order, and generally any MSBuild build issues. Requires an existing .binlog file. DO NOT USE FOR: generating…

dotnet/skills · 79 tokens