Skip to main content
hook official · GitHub

session-logger — GitHub Copilot hook: what it does, how to install

This GitHub Copilot hook records agent session start and end times, working directories, and user prompts into local JSON files for usage auditing.

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/settings.json
Open on GitHub

What session-logger does

The hook monitors GitHub Copilot coding agent lifecycles by intercepting session launches, terminations, and prompt submissions. It stores structured JSON records directly on disk. Session milestones go to logs/copilot/session.log, while prompt inputs land in logs/copilot/prompts.log.

Three bash scripts handle the automation: log-session-start.sh, log-session-end.sh, and log-prompt.sh. Each operation runs with a 5-second timeout. The logger records timestamps alongside the current working directory. You can adjust verbosity with LOG_LEVEL or halt data collection entirely by setting SKIP_LOGGING=true.

Add logs/ to .gitignore immediately to prevent sensitive prompt logs from leaking into remote branches. The shell scripts also fail silently if they lack execution permissions via chmod +x.

What it helps with

  • Audit coding agent activity on local machines
  • Record session start and termination timestamps
  • Store submitted developer prompts in structured JSON
  • Disable event capturing during private work using SKIP_LOGGING=true

Example prompts for the agent

  • Refactor the authentication logic in auth.ts
  • Run the unit test suite and fix failing tests
  • Generate database migration scripts for the user table

How to install session-logger

Manually: put the files in place

.claude/settings.json

The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command

Questions about session-logger

How to install session-logger in GitHub Copilot?

Copy the hook directory to .github/hooks/session-logger, create the log folder with mkdir -p logs/copilot, make scripts executable using chmod +x .github/hooks/session-logger/*.sh, and save the configuration or update .claude/settings.json.

What does session-logger do?

It captures GitHub Copilot agent events, logging start times, end times, working directories, and user prompts to local JSON files. This creates a clean audit trail for your coding sessions.

How to disable logging or restrict it to errors?

Set the SKIP_LOGGING=true environment variable to turn off tracking completely. To log errors only, set LOG_LEVEL=ERROR inside the hook environment configuration.

Source text

session-logger · MIT
---
name: 'Session Logger'
description: 'Logs all Copilot coding agent session activity for audit and analysis'
tags: ['logging', 'audit', 'analytics']
---

# Session Logger Hook

Comprehensive logging for GitHub Copilot coding agent sessions, tracking session starts, ends, and user prompts for audit trails and usage analytics.

## Overview

This hook provides detailed logging of Copilot coding agent activity:
- Session start/end times with working directory context
- User prompt submission events
- Configurable log levels

## Features

- **Session Tracking**: Log session start and end events
- **Prompt Logging**: Record when user prompts are submitted
- **Structured Logging**: JSON format for easy parsing
- **Privacy Aware**: Configurable to disable logging entirely

## Installation

1. Copy this hook folder to your repository's `.github/hooks/` directory:
   ```bash
   cp -r hooks/session-logger .github/hooks/
   ```

2. Create the logs directory:
   ```bash
   mkdir -p logs/copilot
   ```

3. Ensure scripts are executable:
   ```bash
   chmod +x .github/hooks/session-logger/*.sh
   ```

4. Commit the hook configuration to your repository's default branch

## Log Format

Session events are written to `logs/copilot/session.log` and prompt events to `logs/copilot/prompts.log` in JSON format:

```json
{"timestamp":"2024-01-15T10:30:00Z","event":"sessionStart","cwd":"/workspace/project"}
{"timestamp":"2024-01-15T10:35:00Z","event":"sessionEnd"}
```

## Privacy & Security

- Add `logs/` to `.gitignore` to avoid committing session data
- Use `LOG_LEVEL=ERROR` to only log errors
- Set `SKIP_LOGGING=true` environment variable to disable
- Logs are stored locally only


```json
{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": ".github/hooks/session-logger/log-session-start.sh",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "sessionEnd": [
      {
        "type": "command",
        "bash": ".github/hooks/session-logger/log-session-end.sh",
        "cwd": ".",
        "timeoutSec": 5
      }
    ],
    "userPromptSubmitted": [
      {
        "type": "command",
        "bash": ".github/hooks/session-logger/log-prompt.sh",
        "cwd": ".",
        "env": {
          "LOG_LEVEL": "INFO"
        },
        "timeoutSec": 5
      }
    ]
  }
}

```

© github · MIT · github/awesome-copilot

Similar hooks

All hooks for Agent setup: memory, context, orchestration →

From the same set954

The whole set →
ai-prompt-engineering-safety-best-practices This rule guides prompt writing with clear context, constraints, and output formats. It also asks developers to consider safety and bias when creating or reviewing prompts. ★ 40,451repo stars agents A rule file that sets the format for GitHub Copilot custom agent files: which frontmatter fields are required, how tools and handoffs work. ★ 40,451repo stars agent-skills Provides guidelines for creating portable Agent Skills for GitHub Copilot. It ensures SKILL.md files follow proper frontmatter formats, directory structures, and workflow layouts. ★ 40,451repo stars agent-safety This rule sets access controls, policy checks, and audit guidance for code built with AI agents. Use it when implementing tool-calling or multi-agent systems. ★ 40,451repo stars session-auto-commit At the end of a GitHub Copilot session, this hook commits changed files and tries to push them to the remote repository. Use it to save session work automatically. ★ 40,451repo stars secrets-scanner Scans the files a Copilot coding agent touched during a session for leaked keys and credentials before they get committed. Useful when the agent edits code fast. ★ 40,451repo stars governance-audit Scans GitHub Copilot prompts for threat patterns before execution. It records events to a local JSON log and stops destructive actions based on governance settings. ★ 40,451repo stars fix-broken-links This hook checks links in recently edited web files after GitHub Copilot uses a tool. It helps catch dead URLs and vague link labels before they linger in the project. ★ 40,451repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor