[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JGSSZFKQCCX7AAM268M1F9":3,"skill-same:01M6JGSSZFKQCCX7AAM268M1F9":109},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":57,"commitSha":58,"skillDirectory":59,"forksCount":60,"repositoryHtmlUrl":61,"repositoryHomepageUrl":6,"ownerHtmlUrl":62,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":63,"install":64,"resources":77},"01M6JGSSZFKQCCX7AAM268M1F9","golang-samber-slog",null,"Structured logging extensions for Golang using samber\u002Fslog-**** packages — multi-handler pipelines (slog-multi), log sampling (slog-sampling), attribute formatting (slog-formatter), HTTP middleware (slog-fiber, slog-gin, slog-chi, slog-echo), and backend routing (slog-datadog, slog-sentry, slog-loki, slog-syslog, slog-logstash, slog-graylog...). Apply when using or adopting slog, or when the codebase already imports any github.com\u002Fsamber\u002Fslog-* package.","muratovv\u002Fai-hats","muratovv","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7502801?v=4","01M6JGCBN4KEJX012GPJVSH04T","Fedor Muratov","01M6JGCBSNMN7CW3RGTPPE0MN2",3,"MIT","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"golang","golang samber slog","Echo","imports","structured logging","logstash","middleware","loki","false","query","context7","MCP","log","sampling","projects","Bash","syslog","code","packages","ai coding agents","2026-11-10 10:12:30",false,"---\nname: golang-samber-slog\ndescription: >-\n  Structured logging extensions for Golang using samber\u002Fslog-**** packages\n  — multi-handler pipelines (slog-multi), log sampling (slog-sampling),\n  attribute formatting (slog-formatter), HTTP middleware (slog-fiber,\n  slog-gin, slog-chi, slog-echo), and backend routing (slog-datadog,\n  slog-sentry, slog-loki, slog-syslog, slog-logstash, slog-graylog...).\n  Apply when using or adopting slog, or when the codebase already imports\n  any github.com\u002Fsamber\u002Fslog-* package.\nuser-invocable: false\nlicense: MIT\ncompatibility: Designed for Claude Code or similar AI coding agents, and for projects using Golang.\nmetadata:\n  author: samber\n  version: \"1.0.3\"\nallowed-tools: Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs AskUserQuestion\n---\n\n**Persona:** You are a Go logging architect. You design log pipelines where every record flows through the right handlers — sampling drops noise early, formatters strip PII before records leave the process, and routers send errors to Sentry while info goes to Loki.\n\n# samber\u002Fslog-\\*\\*\\*\\* — Structured Logging Pipeline for Go\n\n20+ composable `slog.Handler` packages for Go 1.21+. Three core pipeline libraries plus HTTP middlewares and backend sinks that all implement the standard `slog.Handler` interface.\n\n**Official resources:**\n\n- [github.com\u002Fsamber\u002Fslog-multi](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi) — handler composition\n- [github.com\u002Fsamber\u002Fslog-sampling](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling) — throughput control\n- [github.com\u002Fsamber\u002Fslog-formatter](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-formatter) — attribute transformation\n\nThis skill is not exhaustive. Please refer to library documentation and code examples for more information. Context7 can help as a discoverability platform.\n\n## The Pipeline Model\n\nEvery samber\u002Fslog pipeline follows a canonical ordering. Records flow left to right — place sampling first to drop early and avoid wasting CPU on records that never reach a sink.\n\n```\nrecord → [Sampling] → [Pipe: trace\u002FPII] → [Router] → [Sinks]\n```\n\nOrder matters: sampling before formatting saves CPU. Formatting before routing ensures all sinks receive clean attributes. Reversing this wastes work on records that get dropped.\n\n## Core Libraries\n\n| Library | Purpose | Key constructors |\n| --- | --- | --- |\n| `slog-multi` | Handler composition | `Fanout`, `Router`, `FirstMatch`, `Failover`, `Pool`, `Pipe` |\n| `slog-sampling` | Throughput control | `UniformSamplingOption`, `ThresholdSamplingOption`, `AbsoluteSamplingOption`, `CustomSamplingOption` |\n| `slog-formatter` | Attribute transforms | `PIIFormatter`, `ErrorFormatter`, `FormatByType[T]`, `FormatByKey`, `FlattenFormatterMiddleware` |\n\n## slog-multi — Handler Composition\n\nSix composition patterns, each for a different routing need:\n\n| Pattern | Behavior | Latency impact |\n| --- | --- | --- |\n| `Fanout(handlers...)` | Broadcast to all handlers sequentially | Sum of all handler latencies |\n| `Router().Add(h, predicate).Handler()` | Route to ALL matching handlers | Sum of matching handlers |\n| `Router().Add(...).FirstMatch().Handler()` | Route to FIRST match only | Single handler latency |\n| `Failover()(handlers...)` | Try sequentially until one succeeds | Primary handler latency (happy path) |\n| `Pool()(handlers...)` | Concurrent broadcast to all handlers | Max of all handler latencies |\n| `Pipe(middlewares...).Handler(sink)` | Middleware chain before sink | Middleware overhead + sink |\n\n```go\n\u002F\u002F Route errors to Sentry, all logs to stdout\nlogger := slog.New(\n    slogmulti.Router().\n        Add(sentryHandler, slogmulti.LevelIs(slog.LevelError)).\n        Add(slog.NewJSONHandler(os.Stdout, nil)).\n        Handler(),\n)\n```\n\nBuilt-in predicates: `LevelIs`, `LevelIsNot`, `MessageIs`, `MessageIsNot`, `MessageContains`, `MessageNotContains`, `AttrValueIs`, `AttrKindIs`.\n\nFor full code examples of every pattern, see [Pipeline Patterns](references\u002Fpipeline-patterns.md).\n\n## slog-sampling — Throughput Control\n\n| Strategy | Behavior | Best for |\n| --- | --- | --- |\n| Uniform | Drop fixed % of all records | Dev\u002Fstaging noise reduction |\n| Threshold | Log first N per interval, then sample at rate R | Production — preserves initial visibility |\n| Absolute | Cap at N records per interval globally | Hard cost control |\n| Custom | User function returns sample rate per record | Level-aware or time-aware rules |\n\nSampling MUST be the outermost handler in the pipeline — placing it after formatting wastes CPU on records that get dropped.\n\n```go\n\u002F\u002F Threshold: log first 10 per 5s, then 10% — errors always pass through via Router\nlogger := slog.New(\n    slogmulti.\n        Pipe(slogsampling.ThresholdSamplingOption{\n            Tick: 5 * time.Second, Threshold: 10, Rate: 0.1,\n        }.NewMiddleware()).\n        Handler(innerHandler),\n)\n```\n\nMatchers group similar records for deduplication: `MatchByLevel()`, `MatchByMessage()`, `MatchByLevelAndMessage()` (default), `MatchBySource()`, `MatchByAttribute(groups, key)`.\n\nFor strategy comparison and configuration details, see [Sampling Strategies](references\u002Fsampling-strategies.md).\n\n## slog-formatter — Attribute Transformation\n\nApply as a `Pipe` middleware so all downstream handlers receive clean attributes.\n\n```go\nlogger := slog.New(\n    slogmulti.Pipe(slogformatter.NewFormatterMiddleware(\n        slogformatter.PIIFormatter(\"user\"),          \u002F\u002F mask PII fields\n        slogformatter.ErrorFormatter(\"error\"),       \u002F\u002F structured error info\n        slogformatter.IPAddressFormatter(\"client\"),  \u002F\u002F mask IP addresses\n    )).Handler(slog.NewJSONHandler(os.Stdout, nil)),\n)\n```\n\nKey formatters: `PIIFormatter`, `ErrorFormatter`, `TimeFormatter`, `UnixTimestampFormatter`, `IPAddressFormatter`, `HTTPRequestFormatter`, `HTTPResponseFormatter`. Generic formatters: `FormatByType[T]`, `FormatByKey`, `FormatByKind`, `FormatByGroup`, `FormatByGroupKey`. Flatten nested attributes with `FlattenFormatterMiddleware`.\n\n## HTTP Middlewares\n\nConsistent pattern across frameworks: `router.Use(slogXXX.New(logger))`.\n\nAvailable: `slog-gin`, `slog-echo`, `slog-fiber`, `slog-chi`, `slog-http` (net\u002Fhttp).\n\nAll share a `Config` struct with: `DefaultLevel`, `ClientErrorLevel`, `ServerErrorLevel`, `WithRequestBody`, `WithResponseBody`, `WithUserAgent`, `WithRequestID`, `WithTraceID`, `WithSpanID`, `Filters`.\n\n```go\n\u002F\u002F Gin with filters — skip health checks\nrouter.Use(sloggin.NewWithConfig(logger, sloggin.Config{\n    DefaultLevel:     slog.LevelInfo,\n    ClientErrorLevel: slog.LevelWarn,\n    ServerErrorLevel: slog.LevelError,\n    WithRequestBody:  true,\n    Filters: []sloggin.Filter{\n        sloggin.IgnorePath(\"\u002Fhealth\", \"\u002Fmetrics\"),\n    },\n}))\n```\n\nFor framework-specific setup, see [HTTP Middlewares](references\u002Fhttp-middlewares.md).\n\n## Backend Sinks\n\nAll follow the `Option{}.NewXxxHandler()` constructor pattern.\n\n| Category     | Packages                                                   |\n| ------------ | ---------------------------------------------------------- |\n| Cloud        | `slog-datadog`, `slog-sentry`, `slog-loki`, `slog-graylog` |\n| Messaging    | `slog-kafka`, `slog-fluentd`, `slog-logstash`, `slog-nats` |\n| Notification | `slog-slack`, `slog-telegram`, `slog-webhook`              |\n| Storage      | `slog-parquet`                                             |\n| Bridges      | `slog-zap`, `slog-zerolog`, `slog-logrus`                  |\n\n**Batch handlers require graceful shutdown** — `slog-datadog`, `slog-loki`, `slog-kafka`, and `slog-parquet` buffer records internally. Flush on shutdown (e.g., `handler.Stop(ctx)` for Datadog, `lokiClient.Stop()` for Loki, `writer.Close()` for Kafka) or buffered logs are lost.\n\nFor configuration examples and shutdown patterns, see [Backend Handlers](references\u002Fbackend-handlers.md).\n\n## Common Mistakes\n\n| Mistake | Why it fails | Fix |\n| --- | --- | --- |\n| Sampling after formatting | Wastes CPU formatting records that get dropped | Place sampling as outermost handler |\n| Fanout to many synchronous handlers | Blocks caller — latency is sum of all handlers | Use `Pool()` for concurrent dispatch |\n| Missing shutdown flush on batch handlers | Buffered logs lost on shutdown | `defer handler.Stop(ctx)` (Datadog), `defer lokiClient.Stop()` (Loki), `defer writer.Close()` (Kafka) |\n| Router without default\u002Fcatch-all handler | Unmatched records silently dropped | Add a handler with no predicate as catch-all |\n| `AttrFromContext` without HTTP middleware | Context has no request attributes to extract | Install `slog-gin`\u002F`echo`\u002F`fiber`\u002F`chi` middleware first |\n| Using `Pipe` with no middleware | No-op wrapper adding per-record overhead | Remove `Pipe()` if no middleware needed |\n\n## Performance Warnings\n\n- **Fanout latency** = sum of all handler latencies (sequential). With 5 handlers at 10ms each, every log call costs 50ms. Use `Pool()` to reduce to max(latencies)\n- **Pipe middleware** adds per-record function call overhead — keep chains short (2-4 middlewares)\n- **slog-formatter** processes attributes sequentially — many formatters compound. For hot-path attribute formatting, prefer implementing `slog.LogValuer` on your types instead\n- **Benchmark** your pipeline with `go test -bench` before production deployment\n\n**Diagnose:** measure per-record allocation and latency of your pipeline and identify which handler in the chain allocates most.\n\n## Best Practices\n\n1. **Sample first, format second, route last** — this canonical ordering minimizes wasted work and ensures all sinks see clean data\n2. **Use Pipe for cross-cutting concerns** — trace ID injection and PII scrubbing belong in middleware, not per-handler logic\n3. **Test pipelines with `slogmulti.NewHandleInlineHandler`** — assert on records reaching each stage without real sinks\n4. **Use `AttrFromContext`** to propagate request-scoped attributes from HTTP middleware to all handlers\n5. **Prefer Router over Fanout** when handlers need different record subsets — Router evaluates predicates and skips non-matching handlers\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-observability` skill for slog fundamentals (levels, context, handler setup, migration)\n- → See `samber\u002Fcc-skills-golang@golang-error-handling` skill for the log-or-return rule\n- → See `samber\u002Fcc-skills-golang@golang-security` skill for PII handling in logs\n- → See `samber\u002Fcc-skills-golang@golang-samber-oops` skill for structured error context with `samber\u002Foops`\n\nIf you encounter a bug or unexpected behavior in any samber\u002Fslog-\\* package, open an issue at the relevant repository (e.g., [slog-multi\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi\u002Fissues), [slog-sampling\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling\u002Fissues)).\n","**Persona:** You are a Go logging architect. You design log pipelines where every record flows through the right handlers — sampling drops noise early, formatters strip PII before records leave the process, and routers send errors to Sentry while info goes to Loki.\n\n# samber\u002Fslog-\\*\\*\\*\\* — Structured Logging Pipeline for Go\n\n20+ composable `slog.Handler` packages for Go 1.21+. Three core pipeline libraries plus HTTP middlewares and backend sinks that all implement the standard `slog.Handler` interface.\n\n**Official resources:**\n\n- [github.com\u002Fsamber\u002Fslog-multi](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi) — handler composition\n- [github.com\u002Fsamber\u002Fslog-sampling](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling) — throughput control\n- [github.com\u002Fsamber\u002Fslog-formatter](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-formatter) — attribute transformation\n\nThis skill is not exhaustive. Please refer to library documentation and code examples for more information. Context7 can help as a discoverability platform.\n\n## The Pipeline Model\n\nEvery samber\u002Fslog pipeline follows a canonical ordering. Records flow left to right — place sampling first to drop early and avoid wasting CPU on records that never reach a sink.\n\n```\nrecord → [Sampling] → [Pipe: trace\u002FPII] → [Router] → [Sinks]\n```\n\nOrder matters: sampling before formatting saves CPU. Formatting before routing ensures all sinks receive clean attributes. Reversing this wastes work on records that get dropped.\n\n## Core Libraries\n\n| Library | Purpose | Key constructors |\n| --- | --- | --- |\n| `slog-multi` | Handler composition | `Fanout`, `Router`, `FirstMatch`, `Failover`, `Pool`, `Pipe` |\n| `slog-sampling` | Throughput control | `UniformSamplingOption`, `ThresholdSamplingOption`, `AbsoluteSamplingOption`, `CustomSamplingOption` |\n| `slog-formatter` | Attribute transforms | `PIIFormatter`, `ErrorFormatter`, `FormatByType[T]`, `FormatByKey`, `FlattenFormatterMiddleware` |\n\n## slog-multi — Handler Composition\n\nSix composition patterns, each for a different routing need:\n\n| Pattern | Behavior | Latency impact |\n| --- | --- | --- |\n| `Fanout(handlers...)` | Broadcast to all handlers sequentially | Sum of all handler latencies |\n| `Router().Add(h, predicate).Handler()` | Route to ALL matching handlers | Sum of matching handlers |\n| `Router().Add(...).FirstMatch().Handler()` | Route to FIRST match only | Single handler latency |\n| `Failover()(handlers...)` | Try sequentially until one succeeds | Primary handler latency (happy path) |\n| `Pool()(handlers...)` | Concurrent broadcast to all handlers | Max of all handler latencies |\n| `Pipe(middlewares...).Handler(sink)` | Middleware chain before sink | Middleware overhead + sink |\n\n```go\n\u002F\u002F Route errors to Sentry, all logs to stdout\nlogger := slog.New(\n    slogmulti.Router().\n        Add(sentryHandler, slogmulti.LevelIs(slog.LevelError)).\n        Add(slog.NewJSONHandler(os.Stdout, nil)).\n        Handler(),\n)\n```\n\nBuilt-in predicates: `LevelIs`, `LevelIsNot`, `MessageIs`, `MessageIsNot`, `MessageContains`, `MessageNotContains`, `AttrValueIs`, `AttrKindIs`.\n\nFor full code examples of every pattern, see [Pipeline Patterns](references\u002Fpipeline-patterns.md).\n\n## slog-sampling — Throughput Control\n\n| Strategy | Behavior | Best for |\n| --- | --- | --- |\n| Uniform | Drop fixed % of all records | Dev\u002Fstaging noise reduction |\n| Threshold | Log first N per interval, then sample at rate R | Production — preserves initial visibility |\n| Absolute | Cap at N records per interval globally | Hard cost control |\n| Custom | User function returns sample rate per record | Level-aware or time-aware rules |\n\nSampling MUST be the outermost handler in the pipeline — placing it after formatting wastes CPU on records that get dropped.\n\n```go\n\u002F\u002F Threshold: log first 10 per 5s, then 10% — errors always pass through via Router\nlogger := slog.New(\n    slogmulti.\n        Pipe(slogsampling.ThresholdSamplingOption{\n            Tick: 5 * time.Second, Threshold: 10, Rate: 0.1,\n        }.NewMiddleware()).\n        Handler(innerHandler),\n)\n```\n\nMatchers group similar records for deduplication: `MatchByLevel()`, `MatchByMessage()`, `MatchByLevelAndMessage()` (default), `MatchBySource()`, `MatchByAttribute(groups, key)`.\n\nFor strategy comparison and configuration details, see [Sampling Strategies](references\u002Fsampling-strategies.md).\n\n## slog-formatter — Attribute Transformation\n\nApply as a `Pipe` middleware so all downstream handlers receive clean attributes.\n\n```go\nlogger := slog.New(\n    slogmulti.Pipe(slogformatter.NewFormatterMiddleware(\n        slogformatter.PIIFormatter(\"user\"),          \u002F\u002F mask PII fields\n        slogformatter.ErrorFormatter(\"error\"),       \u002F\u002F structured error info\n        slogformatter.IPAddressFormatter(\"client\"),  \u002F\u002F mask IP addresses\n    )).Handler(slog.NewJSONHandler(os.Stdout, nil)),\n)\n```\n\nKey formatters: `PIIFormatter`, `ErrorFormatter`, `TimeFormatter`, `UnixTimestampFormatter`, `IPAddressFormatter`, `HTTPRequestFormatter`, `HTTPResponseFormatter`. Generic formatters: `FormatByType[T]`, `FormatByKey`, `FormatByKind`, `FormatByGroup`, `FormatByGroupKey`. Flatten nested attributes with `FlattenFormatterMiddleware`.\n\n## HTTP Middlewares\n\nConsistent pattern across frameworks: `router.Use(slogXXX.New(logger))`.\n\nAvailable: `slog-gin`, `slog-echo`, `slog-fiber`, `slog-chi`, `slog-http` (net\u002Fhttp).\n\nAll share a `Config` struct with: `DefaultLevel`, `ClientErrorLevel`, `ServerErrorLevel`, `WithRequestBody`, `WithResponseBody`, `WithUserAgent`, `WithRequestID`, `WithTraceID`, `WithSpanID`, `Filters`.\n\n```go\n\u002F\u002F Gin with filters — skip health checks\nrouter.Use(sloggin.NewWithConfig(logger, sloggin.Config{\n    DefaultLevel:     slog.LevelInfo,\n    ClientErrorLevel: slog.LevelWarn,\n    ServerErrorLevel: slog.LevelError,\n    WithRequestBody:  true,\n    Filters: []sloggin.Filter{\n        sloggin.IgnorePath(\"\u002Fhealth\", \"\u002Fmetrics\"),\n    },\n}))\n```\n\nFor framework-specific setup, see [HTTP Middlewares](references\u002Fhttp-middlewares.md).\n\n## Backend Sinks\n\nAll follow the `Option{}.NewXxxHandler()` constructor pattern.\n\n| Category     | Packages                                                   |\n| ------------ | ---------------------------------------------------------- |\n| Cloud        | `slog-datadog`, `slog-sentry`, `slog-loki`, `slog-graylog` |\n| Messaging    | `slog-kafka`, `slog-fluentd`, `slog-logstash`, `slog-nats` |\n| Notification | `slog-slack`, `slog-telegram`, `slog-webhook`              |\n| Storage      | `slog-parquet`                                             |\n| Bridges      | `slog-zap`, `slog-zerolog`, `slog-logrus`                  |\n\n**Batch handlers require graceful shutdown** — `slog-datadog`, `slog-loki`, `slog-kafka`, and `slog-parquet` buffer records internally. Flush on shutdown (e.g., `handler.Stop(ctx)` for Datadog, `lokiClient.Stop()` for Loki, `writer.Close()` for Kafka) or buffered logs are lost.\n\nFor configuration examples and shutdown patterns, see [Backend Handlers](references\u002Fbackend-handlers.md).\n\n## Common Mistakes\n\n| Mistake | Why it fails | Fix |\n| --- | --- | --- |\n| Sampling after formatting | Wastes CPU formatting records that get dropped | Place sampling as outermost handler |\n| Fanout to many synchronous handlers | Blocks caller — latency is sum of all handlers | Use `Pool()` for concurrent dispatch |\n| Missing shutdown flush on batch handlers | Buffered logs lost on shutdown | `defer handler.Stop(ctx)` (Datadog), `defer lokiClient.Stop()` (Loki), `defer writer.Close()` (Kafka) |\n| Router without default\u002Fcatch-all handler | Unmatched records silently dropped | Add a handler with no predicate as catch-all |\n| `AttrFromContext` without HTTP middleware | Context has no request attributes to extract | Install `slog-gin`\u002F`echo`\u002F`fiber`\u002F`chi` middleware first |\n| Using `Pipe` with no middleware | No-op wrapper adding per-record overhead | Remove `Pipe()` if no middleware needed |\n\n## Performance Warnings\n\n- **Fanout latency** = sum of all handler latencies (sequential). With 5 handlers at 10ms each, every log call costs 50ms. Use `Pool()` to reduce to max(latencies)\n- **Pipe middleware** adds per-record function call overhead — keep chains short (2-4 middlewares)\n- **slog-formatter** processes attributes sequentially — many formatters compound. For hot-path attribute formatting, prefer implementing `slog.LogValuer` on your types instead\n- **Benchmark** your pipeline with `go test -bench` before production deployment\n\n**Diagnose:** measure per-record allocation and latency of your pipeline and identify which handler in the chain allocates most.\n\n## Best Practices\n\n1. **Sample first, format second, route last** — this canonical ordering minimizes wasted work and ensures all sinks see clean data\n2. **Use Pipe for cross-cutting concerns** — trace ID injection and PII scrubbing belong in middleware, not per-handler logic\n3. **Test pipelines with `slogmulti.NewHandleInlineHandler`** — assert on records reaching each stage without real sinks\n4. **Use `AttrFromContext`** to propagate request-scoped attributes from HTTP middleware to all handlers\n5. **Prefer Router over Fanout** when handlers need different record subsets — Router evaluates predicates and skips non-matching handlers\n\n## Cross-References\n\n- → See `samber\u002Fcc-skills-golang@golang-observability` skill for slog fundamentals (levels, context, handler setup, migration)\n- → See `samber\u002Fcc-skills-golang@golang-error-handling` skill for the log-or-return rule\n- → See `samber\u002Fcc-skills-golang@golang-security` skill for PII handling in logs\n- → See `samber\u002Fcc-skills-golang@golang-samber-oops` skill for structured error context with `samber\u002Foops`\n\nIf you encounter a bug or unexpected behavior in any samber\u002Fslog-\\* package, open an issue at the relevant repository (e.g., [slog-multi\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi\u002Fissues), [slog-sampling\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling\u002Fissues)).\n",{"name":5,"license":15,"metadata":52,"description":7,"allowed-tools":55,"compatibility":56,"user-invocable":48},{"author":53,"version":54},"samber","1.0.3","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs AskUserQuestion","Designed for Claude Code or similar AI coding agents, and for projects using Golang.","master","b4819add93efbaf4d80627118ec34680406b309b","packages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog",1,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats","https:\u002F\u002Fgithub.com\u002Fmuratovv","2026-11-05 20:59:10",{"source":8,"skillName":5,"commands":65,"prompt":75,"zipAvailable":76},[66,69,72],{"tool":67,"command":68},"npx","npx skills add muratovv\u002Fai-hats --skill golang-samber-slog",{"tool":70,"command":71},"bunx","bunx skills add muratovv\u002Fai-hats --skill golang-samber-slog",{"tool":73,"command":74},"pnpm","pnpm dlx skills add muratovv\u002Fai-hats --skill golang-samber-slog","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002FSKILL.md",true,[78,84,89,93,97,101,105],{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"evals\u002Fevals.json","REFERENCE","参考文档",14146,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002Fevals\u002Fevals.json",{"path":85,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":87,"sourceHtmlUrl":88},"LICENSE","许可证",1070,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002FLICENSE",{"path":90,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":91,"sourceHtmlUrl":92},"metadata.yaml",662,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002Fmetadata.yaml",{"path":94,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Fbackend-handlers.md",7406,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002Freferences\u002Fbackend-handlers.md",{"path":98,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":99,"sourceHtmlUrl":100},"references\u002Fhttp-middlewares.md",5242,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002Freferences\u002Fhttp-middlewares.md",{"path":102,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":103,"sourceHtmlUrl":104},"references\u002Fpipeline-patterns.md",8333,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002Freferences\u002Fpipeline-patterns.md",{"path":106,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":107,"sourceHtmlUrl":108},"references\u002Fsampling-strategies.md",6604,"https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fusage\u002Fskills\u002Fgolang-samber-slog\u002Freferences\u002Fsampling-strategies.md",[110,137,162,181,205,219],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":114,"categories":115,"keywords":116,"publishedAt":47},"01M6PVFB1SM738R2SRSRSF7CY6","tool-evaluation-protocol","Time-bounded protocol for evaluating new tools, libraries, or methodologies before adoption. Use when evaluating a candidate dependency for the project, researching a methodology (e.g. ML\u002FLLM frameworks, testing approaches), or following up on a hype-driven recommendation.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Ftool-evaluation-protocol\u002FSKILL.md",[],[117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136],"protocol","Evaluation","tool","tool evaluation protocol","testing","ml","libraries","adoption","methodology","Tools","use","dependency","up","frameworks","time","project","recommendation","for","bounded","candidate",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":47},"01M6PVF7HATBEX1G7N50E2QT57","systematic-debugging","4-phase bug-fix protocol (evidence, pattern, hypothesis, verify). Use when investigating any error, failure, or unexpected behavior, handling bug reports from users or monitoring, or diagnosing test failures with non-obvious causes.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fsystematic-debugging\u002FSKILL.md",[],[144,145,146,147,117,148,149,150,151,152,127,153,154,155,156,157,158,159,160,161],"systematic debugging","debugging","systematic","test","monitoring","hypothesis","verify","behavior","fix","evidence","bug","reports","pattern","users","error","with","bug-fix","phase",{"skillNo":163,"name":164,"nameZh":6,"description":165,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":166,"categories":167,"keywords":169,"publishedAt":47},"01M6PVF3MTQN3RPF73AN34856J","skill-template","Canonical template and validation guide for ai-hats skills. Use when creating a new skill, reviewing an existing one for structural compliance, or deciding which pattern fits a new behavior.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fskill-template\u002FSKILL.md",[168],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[170,171,172,173,174,151,175,127,176,156,177,178,179,134,180],"template","skill template","validation","compliance","hats","guide","new skill","structural","canonical","which","Existing",{"skillNo":182,"name":183,"nameZh":6,"description":184,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":185,"categories":186,"keywords":188,"publishedAt":47},"01M6PVF06SCV28QARM5MQPANC9","skill-optimization","Audit and refactor library components to eliminate redundancy and staleness. Use during periodic library maintenance, after adding multiple new skills or rules, when a role's token budget is too high, or after retrospectives identify component issues.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fskill-optimization\u002FSKILL.md",[187],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[189,190,191,192,193,194,195,196,197,198,127,199,200,201,202,203,204],"Optimization","skill optimization","components","component","issues","library","audit","refactor","Budget","Rules","periodic","maintenance","token","token budget","role","high",{"skillNo":206,"name":207,"nameZh":6,"description":208,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":209,"categories":210,"keywords":211,"publishedAt":47},"01M6PVEXM9717016T9MW82HDCT","silent-fallback-gate","PreToolUse hook — refuses an Edit or Write that adds an inert broad except. Use when a Python edit was blocked for a silent fallback.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fsilent-fallback-gate\u002FSKILL.md",[],[212,213,214,215,216,217,127,218,134],"gate","fallback","silent fallback gate","python","write","edit","hook",{"skillNo":220,"name":221,"nameZh":6,"description":222,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":223,"categories":224,"keywords":226,"publishedAt":47},"01M6PVESM49C5NT7SB7N3F76VS","retro-to-framework","Convert an observation about agent behavior — from a retrospective or from a single incident — into a framework-level change (hook, rule, skill, skill update). Use after a retrospective identifies problems that are not project-specific, after an incident where an agent misapplied a component it had read, when CLAUDE.md band-aids accumulate (more than 3 per-project rules that could be generic), or when the same problem recurs across multiple projects.","https:\u002F\u002Fgithub.com\u002Fmuratovv\u002Fai-hats\u002Fblob\u002Fmaster\u002Fpackages\u002Fai-hats-library\u002Fsrc\u002Fai_hats_library\u002Fexperimental\u002Fusage\u002Fskills\u002Fretro-to-framework\u002FSKILL.md",[225],{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},[227,228,229,230,192,231,41,232,198,151,127,233,234,132,235,236,237,238,239,240],"framework","retro","retro to framework","change","retrospective","convert","incident","across","problem","about","more","skill update","single","generic"]