agentskills.codes
CO

console-service

Provides implementation guidance for ConsoleService — the environment-aware console wrapper in this Angular project. Use when adding console logging to any Angular file, using contextConsole, always, never, or opts overrides, checking visibility rules, or understanding how the bootstrap patch gates

Install

mkdir -p .claude/skills/console-service && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15820" && unzip -o skill.zip -d .claude/skills/console-service && rm skill.zip

Installs to .claude/skills/console-service

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Provides implementation guidance for ConsoleService — the environment-aware console wrapper in this Angular project. Use when adding console logging to any Angular file, using contextConsole, always, never, or opts overrides, checking visibility rules, or understanding how the bootstrap patch gates console output. Keywords: console, logging, ConsoleService, contextConsole, always, never, opts, enableConsole, console.log, console.warn, console.error, suppress, force, scoped logger, console gating, production logging, dev logging.
534 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)

About this skill

ConsoleService — Usage Guide

Location

projects/my-app/src/app/core/services/console/
  console.service.ts   ← service, types, contextConsole, opts/always/never
  console.patch.ts     ← patchConsole() bootstrap helper

Path alias: @app/core/services/console/console.service


When to Use This Skill

  • Adding any console.* call in Angular files
  • Deciding whether to use always, never, or opts()
  • Using timers (time/timeEnd/timeLog), groups, table, dir, assert, or count
  • Understanding why a log is or isn't appearing
  • Checking visibility rules for dev vs prod

How It Works

ConsoleService is patched over the native console once in App.ngOnInit() via patchConsole() from console.patch.ts. After that, all console.* calls in the app (including third-party libraries) are automatically gated by ConsoleService.enabled, which is initialised from environment.enableConsole.

EnvironmentenableConsoleDefault behaviour
ng serve (dev)trueAll console output visible
ng build (prod)falseAll console output silent unless force: true

Scoped Logger (Recommended Pattern)

Add one line at the top of any file — no injection needed:

import { contextConsole } from '@app/core/services/console/console.service';

const console = contextConsole('ClassName');

Every console.* call in that file is then auto-prefixed: [ClassName] message.

ALWAYS use contextConsole for any new logging in this project.


Per-Call Overrides

Import always or never alongside contextConsole when needed:

import { contextConsole, always, never } from '@app/core/services/console/console.service';

const console = contextConsole('ClassName');

// Force output even in production:
console.error(always, 'Critical failure:', err);   // → [ClassName] Critical failure: ...

// Permanently silence even in dev:
console.log(never, 'Polling tick');                // → silent

// Normal log — gated by enableConsole:
console.log('[methodName] value:', value);         // → [ClassName] [methodName] value: ...

Use opts({ force, suppress }) for custom combinations not covered by always/never.


Message Prefix Convention

When logging inside a method, include the method name as a prefix string:

console.log('[methodName] label:', value);
// Output: [ClassName] [methodName] label: value

Visibility Rules (evaluated in order)

RuleConditionResult
1suppress: true (per-call)Always silent — wins over everything
2force: true (per-call)Always output — bypasses global toggle
3enabled = falseSilent (no override present)
4enabled = trueOutput

suppress always beats force if both are set.


Available Methods

All methods accept always, never, or opts() as an optional first argument.

MethodNotes
log, warn, error, debug, info, traceStandard output
group(label?), groupCollapsed(label?)Opens a collapsible group
groupEnd()Closes current group
clear()Clears the console
count(label?)Increments named counter
countReset(label?)Resets named counter
time(label?)Starts named timer
timeEnd(label?)Stops timer, logs elapsed
timeLog(label?, ...data)Logs current timer value
assert(condition?, ...data)Logs error if condition is false
table(tabularData?, properties?)Tabular display
dir(item?, options?)Interactive object listing

In contextConsole(), label methods (count, countReset, time, timeEnd, timeLog) automatically prepend the tag to the label.


Quick Reference

IntentSyntax
Scoped logger (recommended)const console = contextConsole('ClassName') at top of file
Normal logconsole.log('[method] label:', value)
Always visible (prod-safe)console.error(always, '[method] msg:', err)
Always silentconsole.log(never, '[method] msg')
Group related logsconsole.group('[method]'); ... console.groupEnd();
Time an operationconsole.time('label'); ... console.timeEnd('label');
Display object treeconsole.dir(obj)
Display array as tableconsole.table(arr)
Runtime enablethis.consoleService.enabled = true
Runtime disablethis.consoleService.enabled = false

Security Rules

  • Never log auth tokens, passwords, API keys, or user PII — even behind never (the text still exists in source).
  • Use always only for operational messages (errors, disconnects) — not data-bearing payloads.
  • Audit any call site that logs HTTP responses or form values before using always.

Search skills

Search the agent skills registry