Token导航 LogoToken导航TokenDH.com
开发需要联网github未标认证来源可访问许可证需确认审计通过

dev-structured-logs开发结构化日志

Agent Skill

dev-structured-logs 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

994

周安装

41

GitHub Stars

60

下载量

325
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

请帮我安装这个 Agent Skill:dev-structured-logs(开发结构化日志)
来源仓库:https://github.com/vasilyu1983/ai-agents-public
仓库路径:skills/dev-structured-logs
安装命令:
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill dev-structured-logs
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/vasilyu1983/ai-agents-public --skill dev-structured-logs

简介

dev-structured-logs 重构传统日志调用为结构化格式,提升可观测性与后期分析效率。

  • 它默认以 dry-run 模式运行,生成机器可读预览与补丁文件,便于人工审核后再应用变更。
  • 专注于 Serilog 等 JSON 日志配置优化,不替代 CI/CD 流程,仅作为代码级日志改造工具。
  • 使用前请备份原日志文件,注意脚本可能修改源代码,建议在版本控制下操作以便回滚。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Structured Logs

Run conservative, review-friendly rewrites for legacy log calls and Serilog JSON config. Default to dry-run and always produce machine-readable preview output.

This is an operation skill for deterministic logging rewrites. Do not use it as a general backend observability or CI/CD guidance skill.

Workflow

  1. Run dry-run first:
python .codex/skills/dev-structured-logs/scripts/structured_logs.py --path <repo> --dry-run
  1. Review:
  • <repo>/patch.diff
  • <repo>/preview-report.json
  1. Apply only after review:
python .codex/skills/dev-structured-logs/scripts/structured_logs.py --path <repo> --apply --backup-dir <dir>
  1. Optionally commit:
python .codex/skills/dev-structured-logs/scripts/structured_logs.py --path <repo> --apply --commit-msg "chore: structured logging migration"

If the task expands into service design, runtime observability strategy, or API-layer refactoring, switch to $software-csharp-backend. If the task expands into nuke/Build.cs or CI execution changes, switch to $ops-nuke-cicd.

CLI Contract

Support these options:

--path <repo>
[--dry-run]
[--apply]
[--preview-file <path>]
[--backup-dir <dir>]
[--enable-handler-scope]
[--handler-pattern <pattern>]
[--log-framework <serilog|microsoft|auto>]
[--exclude <glob>] (repeatable)
[--commit-msg "message"]

Behavior:

  • Default mode is dry-run when --apply is not provided.
  • CommandHandler scope insertion is disabled by default; enable it explicitly with --enable-handler-scope.
  • Do not touch excluded/generated folders: bin/, obj/, node_modules/, packages/, .git/, .vs/.
  • Flag risky rewrites in preview-report.json with risk_level and reason.

Part 1: Logging Transformation Rules

Rewrite only logger.Log* and _logger.Log* style invocations where message argument uses:

  • String concatenation
  • String.Format(...)
  • String interpolation ($"...")

Transform to message templates with properties and argument list. Preserve interpolation expressions as argument expressions (including ternary expressions).

Preserve:

  • Exception overload ordering (LogError(ex, "...", args...))
  • Original expression order

If any message argument has potential side effects (method call, new, increment/decrement, compound assignment):

  • Extract expression to temporary variable before logging call
  • Mark change as manual review in report

Do not attempt risky cross-statement rewrites. Keep changes local to call sites.

Part 2: CommandHandler Scope Rules

Detect handlers by either:

  • Class implementing ICommandHandler<T>
  • Public methods matching handler pattern (default Handle|HandleAsync) with first parameter treated as command object

When --enable-handler-scope is set, at method start insert scope when missing:

  • Build dictionary from command key properties: UserId, TransactionId, TransferId, VerificationId, SessionId, Id
  • Initialize scope items with dictionary collection initializer style, for example:
var __scopeItems = new Dictionary<string, object>
{
    ["Property1"] = command.Property1
};
  • Use using var _scope = _logger.BeginScope(__scopeItems);

Skip if an equivalent command-property BeginScope block already exists in method prologue.

Part 3: Serilog appsettings Rules

Auto-detect Serilog via *.csproj package references containing Serilog, Serilog.*, or Sc.Infrastructure.Serilog. If any *.csproj file contains one of those package names, treat repository as Serilog-enabled and apply Serilog configuration updates to all appsettings.json files in the repository.

If Serilog is detected, inspect all appsettings.json files in the repository.

For each Serilog File sink with object Args (including nested WriteTo pipelines such as Async -> Logger -> configureLogger -> WriteTo):

  • Ensure Args.path ends with .json
  • If Args.path is a debug log file path (for example *.debug), rename it to .debug.json
  • Set Args.formatter to:

- Sc.Infrastructure.Serilog.CustomJsonFormatter, Sc.Infrastructure.Serilog

  • Remove Args.outputTemplate

Do not modify non-File sinks. If Serilog section or File sink does not exist, do nothing.

Outputs

Always produce in repo root:

  • patch.diff unified diff
  • preview-report.json entries:

- file - line - original - transformed - risk_level - reason

When applying:

  • Create backups in --backup-dir or .codex/skills/dev-structured-logs/backups
  • Apply file updates
  • If --commit-msg is supplied, attempt git commit

Examples

Use files in examples/ to validate behavior:

  • concatenation.before.cs / concatenation.after.cs
  • string-format.before.cs / string-format.after.cs
  • interpolation.before.cs / interpolation.after.cs
  • side-effect.before.cs / side-effect.after.cs
  • handler-scope.before.cs / handler-scope.after.cs
  • appsettings.before.json / appsettings.after.json

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

34.84%
按下载量换算113

Claude

34%
按下载量换算111

Cursor

19.08%
按下载量换算62

Gemini CLI

9.59%
按下载量换算31

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

来源信息

继续浏览同类 Skills