一键导入
eng-logging
Use when implementing logging in application code. Covers log level selection, structured logging, error tracking integration, and avoiding noise.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when implementing logging in application code. Covers log level selection, structured logging, error tracking integration, and avoiding noise.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | eng-logging |
| description | Use when implementing logging in application code. Covers log level selection, structured logging, error tracking integration, and avoiding noise. |
| tier | domain |
| globs | ["**/logger*","**/logging*","**/*.service.*","**/*.controller.*","**/*.handler.*","**/*.worker.*","**/*.middleware.*","**/*.interceptor.*"] |
| alwaysApply | false |
PURPOSE: Guidelines for appropriate log levels and structured logging to keep error tracking actionable and signal-to-noise ratio high.
Errors should be actionable. Warnings are informational.
logger.error() -- Goes to error tracking (Sentry, Datadog, etc.) -- Requires human actionlogger.warn() -- Goes to logs only -- FYI, already handledlogger.info() -- Significant state changes -- standard operational visibilitylogger.debug() -- Detailed diagnostics -- verbose, off in production by defaultUse logger.error() when the situation requires immediate investigation or action:
Rule of thumb: If you log it as error, someone should investigate. If nobody needs to investigate, it's not an error.
Use logger.warn() when the application handles the error gracefully and continues:
Use logger.info() for operational visibility into what the application is doing:
Rule of thumb: If you were investigating a production issue, what would you want to see in the logs? That's info.
Use logger.debug() for verbose information useful during development or troubleshooting:
Always include context with log messages. Structured fields are searchable; prose embedded in strings is not.
Include these fields when available:
| Field | When | Why |
|---|---|---|
requestId | Any request-scoped operation | Correlate logs across a single request |
userId | User-initiated actions | Know who was affected |
entity / entityId | Entity operations | Know what was affected |
operation | Service methods | Know what was attempted |
duration | Timed operations | Spot slow operations |
error | Catch blocks | Preserve stack trace and error type |
Good -- structured context:
logger.error('Failed to process payment', {
requestId,
userId,
orderId,
amount,
error: error.message,
stack: error.stack,
});
Bad -- buried context in string:
logger.error(`Failed to process payment for user ${userId} order ${orderId}`);
The bad example loses the ability to filter/search by userId or orderId in log aggregation tools.
token: "...abc123"userId: "usr_123" not user: "Jane Doe"A user requesting a resource that doesn't exist is normal. The 404 response is the correct behavior. Don't treat it as an error.
// BAD -- logs error for normal operation
user = findById(id);
if (!user) {
logger.error('User not found'); // This is not an error!
throw NotFoundException('User not found');
}
// GOOD -- no log needed, the exception is the response
user = findById(id);
if (!user) {
throw NotFoundException('User not found');
}
Info logs for every database query, every cache hit, or every successful API call create noise that drowns out the signal.
// BAD -- noise
logger.info('Successfully fetched user');
logger.info('Successfully updated user');
logger.info('Cache hit for user');
// GOOD -- log the boundary, not every step
logger.info('Request completed', { requestId, duration, status: 200 });
If you log an error and then throw it, the caller will likely log it again. Log at the point where the error is handled, not at every level it passes through.
// BAD -- logged twice (here and in the caller's catch block)
try {
result = await riskyOperation();
} catch (error) {
logger.error('Operation failed', error);
throw error; // Caller will also log this!
}
// GOOD -- let the handler log it
try {
result = await riskyOperation();
} catch (error) {
throw new ServiceException('Operation failed', { cause: error });
}
// The top-level error handler logs it once
Does the error prevent the operation from completing successfully?
|-- Yes --> Is the error thrown/rethrown?
| |-- Yes --> logger.error()
| +-- No --> Does the user get an error response?
| |-- Yes --> logger.warn()
| +-- No --> logger.error()
+-- No --> Has the error been handled?
|-- Yes (fallback/retry/default) --> logger.warn()
+-- No --> logger.error()
logger.error() should be the threshold for alerting tools (Sentry, Datadog, PagerDuty, etc.). This means:
logger.error() call may trigger an alert -- make sure it's worth someone's attentionlogger.warn() is visible in log aggregation but does NOT page anyoneBefore using logger.error(), ask:
If you answered "yes" to all, use ERROR. Otherwise, use WARN.
Remember: If the application keeps working (with fallback/default/retry), it's a WARN, not an ERROR.
Use when you have an approved design or requirements for a multi-step task, before touching code. Turns designs into implementation plans with bite-sized TDD-oriented tasks, exact file paths, and verification steps. Save to docs/plans/.
Use when starting development work on a bug, feature, improvement, or task. Guides engineers through the full development pipeline: discover, brainstorm, plan, execute, review, ship. Invoked by "let's work on", "I need to build", "fix this bug", "start a new task", or /kickoff.
Use when exploring ideas, comparing approaches, or refining an unclear problem — at any point in the workflow. A discovery-time tool, not a pipeline stage. Invokable directly via /brainstorm or offered by kickoff during DISCOVER. Produces understanding, not artifacts.
Use when you have an implementation plan and want to execute it. Analyzes the plan's task graph, determines the best execution strategy (parallel via team-dev or serial via sdd), and orchestrates the full build with quality gates. The single entry point for plan execution — you don't need to choose between team-dev and sdd yourself.
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes. Enforces root cause investigation through four phases: investigation, pattern analysis, hypothesis testing, and implementation. Prevents guess-and-check thrashing.
Use when creating new skills, specialists, agents, or packs for the Jig framework. Guides the user through an interview to determine what to build, scaffolds the artifact with valid frontmatter, checks for overlap with existing artifacts, and verifies it loads correctly. Triggered by "create a skill", "add a specialist", "extend the framework", or /extend.