CFN Log Operations Skill

**Specialization**: Distributed logging, log aggregation, and monitoring

14 stars

Best use case

CFN Log Operations Skill is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

**Specialization**: Distributed logging, log aggregation, and monitoring

Teams using CFN Log Operations Skill should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/log/SKILL.md --create-dirs "https://raw.githubusercontent.com/masharratt/claude-flow-novice/main/.claude/skills/cfn-operations/lib/log/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/log/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How CFN Log Operations Skill Compares

Feature / AgentCFN Log Operations SkillStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

**Specialization**: Distributed logging, log aggregation, and monitoring

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# CFN Log Operations Skill

**Specialization**: Distributed logging, log aggregation, and monitoring

**Part of**: Task 4.4 Distributed Logging Standardization

## Overview

The CFN Log Operations skill provides comprehensive logging capabilities for the CFN system, including:

- **Log Search and Filtering**: Query logs by correlation ID, agent ID, task ID, or timestamp
- **Log Aggregation**: Combine logs from multiple sources into unified searchable formats
- **Log Rotation and Cleanup**: Manage log lifecycle with retention policies
- **Performance Monitoring**: Track logging overhead and system impact
- **Error Tracking**: Monitor and alert on ERROR/FATAL level logs

## Usage

```bash
./.claude/skills/cfn-log-operations/execute.sh [COMMAND] [OPTIONS]
```

### Commands

#### search
Search for logs matching specific criteria.

**Syntax**:
```bash
./execute.sh search [OPTIONS]
```

**Options**:
- `--correlation-id ID` - Search by correlation ID
- `--agent-id ID` - Search by agent ID
- `--task-id ID` - Search by task ID
- `--level LEVEL` - Filter by log level (debug, info, warn, error)
- `--since DURATION` - Logs from last N hours/minutes (e.g., 24h, 2h)
- `--pattern PATTERN` - Grep pattern for message
- `--source SOURCE` - Filter by source container/service
- `--format FORMAT` - Output format (json, text, csv)
- `--limit COUNT` - Limit results (default: 100)

**Examples**:
```bash
# Search by correlation ID
./execute.sh search --correlation-id "task:task-001:agent"

# Find all errors in last 24 hours
./execute.sh search --level error --since 24h

# Find logs from specific agent
./execute.sh search --agent-id "backend-dev-001" --format json

# Search with message pattern
./execute.sh search --pattern "connection" --since 2h
```

#### aggregate
Aggregate logs from multiple sources into unified log files.

**Syntax**:
```bash
./execute.sh aggregate [OPTIONS]
```

**Options**:
- `--source SOURCE` - Log source (docker, filesystem, all)
- `--output OUTPUT_DIR` - Output directory
- `--since DURATION` - Only aggregate recent logs
- `--deduplicate` - Remove duplicate entries
- `--validate` - Validate JSON structure
- `--compress` - Compress aggregated logs
- `--correlate-by FIELD` - Group by field (correlationId, agentId, taskId)

**Examples**:
```bash
# Aggregate all logs from last 24 hours
./execute.sh aggregate --source all --since 24h

# Aggregate and deduplicate
./execute.sh aggregate --source filesystem --deduplicate --validate

# Aggregate with compression
./execute.sh aggregate --source docker --compress
```

#### rotate
Manage log rotation and retention.

**Syntax**:
```bash
./execute.sh rotate [OPTIONS]
```

**Options**:
- `--log-dir DIR` - Directory to rotate (default: /var/log/cfn)
- `--max-size SIZE` - Maximum file size (e.g., 100M)
- `--max-files COUNT` - Maximum rotated files to keep
- `--compress` - Compress rotated logs
- `--retention-days DAYS` - Retention period
- `--force` - Force rotation even if not due

**Examples**:
```bash
# Rotate all logs
./execute.sh rotate

# Rotate with custom size and retention
./execute.sh rotate --max-size 50M --retention-days 30

# Force rotation with compression
./execute.sh rotate --force --compress
```

#### monitor
Monitor logs for errors and performance issues.

**Syntax**:
```bash
./execute.sh monitor [OPTIONS]
```

**Options**:
- `--interval SECONDS` - Check interval (default: 60)
- `--alert-on LEVEL` - Alert levels (default: error,fatal)
- `--error-threshold COUNT` - Error count threshold
- `--action ACTION` - Alert action (log, email, webhook)
- `--performance-check` - Enable performance monitoring
- `--retention-check` - Enable retention compliance check
- `--daemon` - Run as daemon

**Examples**:
```bash
# Monitor with default settings
./execute.sh monitor

# Monitor with custom error threshold
./execute.sh monitor --error-threshold 20

# Monitor as daemon with performance checks
./execute.sh monitor --daemon --performance-check --retention-check
```

#### stats
Generate log statistics and metrics.

**Syntax**:
```bash
./execute.sh stats [OPTIONS]
```

**Options**:
- `--log-dir DIR` - Directory to analyze
- `--since DURATION` - Time window for analysis
- `--format FORMAT` - Output format (json, text)

**Examples**:
```bash
# Get log statistics
./execute.sh stats

# Statistics for last 24 hours
./execute.sh stats --since 24h --format json
```

#### export
Export logs in various formats.

**Syntax**:
```bash
./execute.sh export [OPTIONS]
```

**Options**:
- `--source SOURCE` - Log source directory
- `--format FORMAT` - Output format (json, csv, tsv)
- `--output FILE` - Output file
- `--filter PATTERN` - Filter logs before export

**Examples**:
```bash
# Export to CSV
./execute.sh export --format csv --output logs.csv

# Export errors to JSON
./execute.sh export --filter "level==error" --format json
```

## Log Format Specification

All logs follow the standardized JSON format:

```json
{
  "timestamp": "2025-11-16T03:00:00Z",
  "level": "info",
  "message": "Task completed successfully",
  "correlationId": "task:task-001:agent",
  "source": "cfn-agent-container",
  "context": {
    "agentId": "backend-dev-001",
    "taskId": "task-001",
    "iteration": 1,
    "sprintId": "sprint-4"
  },
  "metadata": {
    "duration": 5000,
    "confidence": 0.92,
    "tags": ["task-execution", "success"]
  }
}
```

### Required Fields
- `timestamp`: ISO 8601 UTC timestamp
- `level`: debug, info, warn, error, fatal
- `message`: Human-readable message
- `source`: Container/service name

### Optional Fields
- `correlationId`: Format: `type:id:agent` (e.g., `task:task-001:agent`)
- `context`: Additional context (agentId, taskId, iteration, sprintId)
- `metadata`: Operation-specific metadata (duration, confidence, tags)
- `error`: Error details (name, message, stack)

## Search Patterns

### Using jq

```bash
# Find all error logs
jq 'select(.level=="error")' logs/*.json

# Filter by correlation ID
jq 'select(.correlationId=="task-001:task:agent")' logs/*.json

# Find logs by agent
jq 'select(.context.agentId=="backend-dev-001")' logs/*.json

# Count errors by source
jq 'select(.level=="error") | .source' logs/*.json | sort | uniq -c

# Complex query: errors in last hour
jq 'select(.level=="error" and .timestamp > "'$(date -u -d '1 hour ago' +'%Y-%m-%dT%H:%M:%SZ')'")' logs/*.json

# Export to CSV
jq -r '[.timestamp, .level, .message, .source] | @csv' logs/*.json
```

### Using grep and awk

```bash
# Find error logs
grep '"level":"error"' logs/*.json

# Find logs by task ID
grep 'task-001' logs/*.json | jq '.'

# Count log levels
grep -o '"level":"[^"]*"' logs/*.json | sort | uniq -c

# Find slow operations (duration > 5000ms)
jq 'select(.metadata.duration > 5000)' logs/*.json
```

## Troubleshooting

### No logs found
- Check log directory path: `/var/log/cfn/`
- Verify log files exist: `ls -la /var/log/cfn/`
- Check permissions: `stat /var/log/cfn/`

### JSON parsing errors
- Validate log format: `./.claude/skills/cfn-log-operations/execute.sh search --validate`
- Check file encoding: `file logs/*.log`
- Review recent logs: `tail -50 logs/*.log`

### Performance issues
- Reduce search scope: use `--since` flag
- Limit results: use `--limit` flag
- Check disk space: `df /var/log/cfn`

### Retention not working
- Verify logrotate config: `/etc/logrotate.d/cfn-logs`
- Test logrotate: `logrotate -d /etc/logrotate.d/cfn-logs`
- Check permissions: files should be readable by logrotate

## Integration

This skill integrates with:
- Docker logging driver (json-file)
- Logrotate for log rotation and retention
- Application logging utilities (`src/lib/logging.ts`)
- Monitoring systems (custom alerting)

## Performance Targets

- Search operation: <500ms for 1GB of logs
- Aggregation: <5% CPU overhead
- Monitoring: <1% memory overhead when running as daemon
- 90%+ structured JSON logs (10% unstructured OK)

## Related Tasks

- **Task 0.5**: Logging utilities (`src/lib/logging.ts`)
- **Task 4.1**: Integration infrastructure
- **Task 4.4**: Distributed logging standardization

Related Skills

File Operations Skill

14
from masharratt/claude-flow-novice

Centralized file locking and atomic write operations for bash scripts.

cfn-operations

14
from masharratt/claude-flow-novice

File and log operations for CFN

supabase-schema-sync

14
from masharratt/claude-flow-novice

Introspects Supabase DB after migrations and updates project db-query skill with current schema. Run after any migration to keep agent context accurate.

commit

14
from masharratt/claude-flow-novice

Stage, commit, and push changes using a background github-commit-agent. Accepts optional args for message override or push control.

cfn-vote-implement

14
from masharratt/claude-flow-novice

MUST BE USED after cfn-dry-review or cfn-alpha-launch:manifest produces a manifest. Also the verification phase of /cfn-loop-task. Do not manually implement code review suggestions - always route through this skill. 3-agent specialized voting. Unanimous (3/3) auto-implemented with TDD. 2/3 routed to product-owner agent. 1/3 surfaced to user via AskUserQuestion (batched 4 per call, at end).

cfn-utilities

14
from masharratt/claude-flow-novice

Reusable bash utility functions for CFN Loop - logging, error handling, retry, file operations. Use when you need structured logging, atomic file operations, retry logic with exponential backoff, or standardized error handling in bash scripts.

CFN Test Runner Skill

14
from masharratt/claude-flow-novice

**Version:** 1.0.0

cfn-test-framework

14
from masharratt/claude-flow-novice

Test execution, running, and webapp testing for CFN

cfn-task-planning

14
from masharratt/claude-flow-novice

Classify tasks, initialize structured configs with scope boundaries, decompose complex tasks

Specialist Injection Skill

14
from masharratt/claude-flow-novice

## Purpose

!/bin/bash

14
from masharratt/claude-flow-novice

# cfn-task-intelligence.sh

Task Complexity Estimator

14
from masharratt/claude-flow-novice

**Version:** 1.0.0