AgentSkillsCN

session-interaction-logger

在每次与 AI 的交互中,将此技能作为工作流的最后一环加以运用。其目的在于全面记录所有 AI 交互、提示、响应、决策、文件变更及命令,以形成完整的审计追踪。适用于开启会话时、每次收到用户提示后、进行代码修改时、执行命令时,或当被要求“记录交互”、“导出会话”、“生成审计报告”或“展示 AI 历史”时使用。特别适用于需要完整项目历史记录,并附带 AI 引导背景信息的评估场景。

SKILL.md
--- frontmatter
name: session-interaction-logger
description: 'Use this skill as last step in your workflow for EVERY interaction with the AI. The purpose is to provide comprehensive logging of ALL AI interactions, prompts, responses, decisions, file changes, and commands for full audit trail. Use when starting a session, after each user prompt, when making code changes, running commands, or when asked to "log interaction", "export session", "generate audit report", or "show AI history". Designed for evaluation scenarios requiring complete project history with AI steering context.'

Session Interaction Logger

Comprehensive, detailed logging of every AI-assisted interaction for audit trails, evaluation evidence, and project history documentation.

Overview

This skill enhances the existing session-logger hook to capture full interaction detail — not just events, but the complete content of prompts, AI reasoning, decisions made, files modified, commands executed, and test results. All logs are stored in logs/copilot/ as structured JSON for easy parsing and report generation.

When to Use This Skill

  • At the start of every coding session (automatic via hook)
  • After each user prompt to log the full request context
  • When making code changes to record what was modified and why
  • When running commands to capture inputs and outputs
  • When asked to export or generate an audit report
  • When preparing deliverables for AI-usage evaluation

Why This Skill Exists

This project is being evaluated on:

  1. Full project history with prompts, context, and chat histories used to steer the AI
  2. Robust automated tests (Unit and Integration) proving correctness and reliability
  3. Clear documentation of decisions, assumptions, and how output was refined

This skill provides artifact #1 — a complete, verifiable record of all AI interactions.

Log Files

All logs are written to logs/copilot/ (created automatically):

FilePurposeFormat
session.logSession start/end eventsJSONL
prompts.logPrompt submission eventsJSONL
interactions.logFull interaction detail (prompt + response + context)JSONL
file-changes.logEvery file created/modified/deleted with diffsJSONL
commands.logEvery terminal command and its output summaryJSONL
decisions.logArchitectural and design decisions with rationaleJSONL
session-report.mdHuman-readable session summary (on-demand export)Markdown

Log Schema

interactions.log

json
{
  "timestamp": "2026-02-14T10:30:00Z",
  "sessionId": "abc123",
  "sequenceNumber": 1,
  "type": "user-prompt | ai-response | clarification | refinement",
  "content": "Full text of the prompt or response",
  "context": {
    "activeFile": "src/main/java/com/addi/challenge/Main.java",
    "openFiles": ["..."],
    "taskInProgress": "Implement lead validation"
  },
  "metadata": {
    "tokensEstimate": 150,
    "toolsUsed": ["read_file", "create_file"],
    "filesReferenced": ["design-doc.md"]
  }
}

file-changes.log

json
{
  "timestamp": "2026-02-14T10:35:00Z",
  "sessionId": "abc123",
  "action": "create | modify | delete",
  "filePath": "src/main/java/com/addi/challenge/domain/Lead.java",
  "reason": "Implement Lead record per design doc section 3.2",
  "linesAdded": 25,
  "linesRemoved": 0,
  "diffSummary": "Created Lead record with fields: id, firstName, lastName, email, birthDate, nationalId"
}

commands.log

json
{
  "timestamp": "2026-02-14T10:40:00Z",
  "sessionId": "abc123",
  "command": "./gradlew test",
  "purpose": "Run unit tests after implementing Lead validation",
  "exitCode": 0,
  "outputSummary": "BUILD SUCCESSFUL - 12 tests passed",
  "duration": "3.2s"
}

decisions.log

json
{
  "timestamp": "2026-02-14T10:32:00Z",
  "sessionId": "abc123",
  "decision": "Use Java Records for domain model",
  "rationale": "Records provide immutability, auto-generated equals/hashCode/toString, and align with Java 25 best practices",
  "alternatives": ["Traditional POJO with Lombok", "Plain class with manual methods"],
  "context": "Design doc section 3.2 specifies immutable domain objects",
  "category": "architecture | design | implementation | testing | tooling"
}

Step-by-Step Workflows

Workflow 1: Log a Full Interaction

After every user prompt and your response, append to logs/copilot/interactions.log:

  1. Generate a sessionId (reuse from session start or generate UUID)
  2. Increment sequenceNumber for ordering
  3. Log the user's prompt with type: "user-prompt"
  4. Log your response summary with type: "ai-response"
  5. Include context: active file, task being worked on, tools used

Script: Use scripts/log-interaction.sh to append entries:

bash
.github/skills/session-interaction-logger/scripts/log-interaction.sh \
  --type "user-prompt" \
  --content "Implement the Lead domain record" \
  --active-file "Main.java" \
  --session-id "$SESSION_ID"

Workflow 2: Log File Changes

Every time you create, modify, or delete a file:

  1. Record the file path, action type, and reason
  2. Summarize the diff (lines added/removed, key changes)
  3. Append to logs/copilot/file-changes.log

Workflow 3: Log Commands

Every time a terminal command is executed:

  1. Record the command, its purpose, and output summary
  2. Include exit code and duration
  3. Append to logs/copilot/commands.log

Workflow 4: Log Decisions

When making architectural or design decisions:

  1. State the decision clearly
  2. Document the rationale and alternatives considered
  3. Reference relevant context (design doc sections, requirements)
  4. Append to logs/copilot/decisions.log

Workflow 5: Export Session Report

When asked to export or generate a report, run:

bash
.github/skills/session-interaction-logger/scripts/export-session-report.sh

This generates logs/copilot/session-report.md with:

  • Session timeline
  • All prompts and response summaries
  • Files created/modified with reasons
  • Commands executed with results
  • Decisions made with rationale
  • Test results summary

Integration with Existing Hooks

This skill enhances the existing session-logger hook scripts. The hooks capture events automatically; this skill adds content-level detail on top of those events.

HookExisting BehaviorEnhanced Behavior
sessionStartLogs timestamp + cwdAlso initializes session ID, creates interaction log header
sessionEndLogs timestampAlso generates session summary stats
userPromptSubmittedLogs timestampAlso captures full prompt text and context

Best Practices

PracticeWhy
Log immediately after each actionEnsures nothing is lost if session ends unexpectedly
Use structured JSON (JSONL)Enables programmatic analysis and report generation
Include rationale with every changeEvaluators want to see why, not just what
Summarize diffs, don't dump raw codeKeeps logs readable while preserving intent
Track sequence numbersAllows reconstructing the exact order of interactions
Reference design doc sectionsLinks implementation decisions to requirements

Privacy & Security

  • logs/ is in .gitignore — logs never get committed by accident
  • No secrets, tokens, or credentials are logged
  • Prompt content is logged as-is; ensure no sensitive data in prompts
  • To disable: set SKIP_LOGGING=true environment variable

Quick Reference

bash
# View latest interactions
tail -20 logs/copilot/interactions.log | jq .

# Count interactions in current session
wc -l logs/copilot/interactions.log

# View all decisions
cat logs/copilot/decisions.log | jq .

# Export full session report
.github/skills/session-interaction-logger/scripts/export-session-report.sh

# View file change history
cat logs/copilot/file-changes.log | jq '.filePath + " - " + .action + " - " + .reason'