fiber-logging-and-project-structure
10
总安装量
9
周安装量
#30004
全站排名
安装命令
npx skills add https://github.com/oimiragieo/agent-studio --skill fiber-logging-and-project-structure
Agent 安装分布
github-copilot
8
continue
7
gemini-cli
7
amp
7
codex
7
kimi-cli
7
Skill 文档
Fiber Logging And Project Structure Skill
- Implement proper logging with Fiber’s Logger middleware
- Follow Fiber’s best practices for project structure
- Use environment variables for configuration
Iron Laws
- ALWAYS use structured logging (zerolog or logrus with JSON output) â never use
fmt.Printlnorlog.Printfin production Fiber applications; unstructured logs cannot be parsed by log aggregators. - NEVER put business logic in route handlers â always call a service/controller layer; route handlers must only handle HTTP concerns (parsing, validation, response writing).
- ALWAYS use Fiber’s
ctx.Locals()for request-scoped values (user ID, trace ID) â never pass request-scoped data via global variables or function parameters down the call stack. - NEVER commit sensitive configuration directly in code â use
envconfig,viper, or environment variables with a.env.exampletemplate; loaded secrets must never appear in logs. - ALWAYS organize project structure into
cmd/,internal/,pkg/conventions â Fiber projects that put all code in root packages become unmaintainable at scale.
Anti-Patterns
| Anti-Pattern | Why It Fails | Correct Approach |
|---|---|---|
fmt.Println for logging in Fiber handlers |
Unstructured; no log levels; no correlation IDs; breaks log aggregation | Use zerolog or logrus with zap.String("key", value) structured fields |
| Business logic in route handlers | Logic becomes untestable and non-reusable; couples HTTP layer to domain | Move to service layer; handler calls service method, formats response |
| Global state for request context | Concurrent requests overwrite each other’s context; race conditions | Use ctx.Locals("key", value) for all request-scoped data |
| Hardcoded config values | No environment-specific deployments; credentials in source history | Use envconfig or viper with .env.example; never commit real values |
| All files in project root | Impossible to separate public/internal APIs; package import cycles | Use standard Go layout: cmd/, internal/, pkg/, api/ |
Memory Protocol (MANDATORY)
Before starting:
cat .claude/context/memory/learnings.md
After completing: Record any new patterns or exceptions discovered.
ASSUME INTERRUPTION: Your context may reset. If it’s not in memory, it didn’t happen.