---
id: post/demiliani-com/14011
type: post
title: Visual Studio Code Agent hook for auditing your AL coding sessions.
summary: Explains VS Code Agent Hooks (in preview) as deterministic shell commands that run at agent lifecycle events, as opposed to skills that the model decides to use. The author shares a hook for AL projects that logs SessionStart, PreToolUse and PostToolUse events to a Markdown audit file, which records reads, commands and session context that Git history misses.
tier: community
language: en
tags:
  - agent hooks
  - al development
  - auditing
  - security
  - compliance
  - visual studio code
  - ai coding agents
system: development
review:
  state: reviewed
  by: opus
  at: "2026-10-08T01:54:08.766Z"
  flags: []
generated:
  at: "2026-10-08T01:26:53.141Z"
  pipeline: 0.2.0
  prompts:
    extract-post: 1
  input_hash: 1223c58f344c7c91823b4adc21a5fa69501ff5ef9add02b36186be418430e8ab
evidence:
  - kind: blog
    url: https://demiliani.com/2026/07/30/visual-studio-code-agent-hook-for-auditing-your-al-coding-sessions/
    title: Visual Studio Code Agent hook for auditing your AL coding sessions.
    date: "2026-07-30"
    commit: null
    t: null
    quote: null
  - kind: blog
    url: https://demiliani.com/2026/07/30/visual-studio-code-agent-hook-for-auditing-your-al-coding-sessions/
    title: Visual Studio Code Agent hook for auditing your AL coding sessions.
    date: "2026-07-30"
    commit: null
    t: null
    quote: Hooks enable you to execute custom shell commands at key lifecycle points during agent sessions.
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
post_id: "14011"
source_id: demiliani-com
source_name: Stefano Demiliani
url: https://demiliani.com/2026/07/30/visual-studio-code-agent-hook-for-auditing-your-al-coding-sessions/
published_at: "2026-07-30T14:55:28.000Z"
author: Stefano Demiliani
full_text: false
words: 1132
quotes:
  - text: Hooks enable you to execute custom shell commands at key lifecycle points during agent sessions.
    why_it_matters: Explains the core mechanism of agent hooks for automation and control during AI-assisted coding.
code_objects_mentioned: []
systems:
  - development
  - copilot
versions_mentioned: []
preview:
  embeddable: true
  frame_url: https://demiliani.com/2026/07/30/visual-studio-code-agent-hook-for-auditing-your-al-coding-sessions/embed/
  image: https://demiliani.com/wp-content/uploads/2026/07/vscode_alhook_01.png
  image_alt: null
  image_w: 1306
  image_h: 269
  site_name: Stefano Demiliani
  favicon: https://demiliani.com/wp-content/uploads/2022/09/sd_wordpress_logo.png?w=32
  probed_at: "2026-10-07T11:50:24.976Z"
---

# Visual Studio Code Agent hook for auditing your AL coding sessions.

[Read the post](https://demiliani.com/2026/07/30/visual-studio-code-agent-hook-for-auditing-your-al-coding-sessions/) · Stefano Demiliani (Stefano Demiliani, MVP) · 2026-07-30 · 1132 words · tier community · reviewed (checked by Opus)

> Explains VS Code Agent Hooks (in preview) as deterministic shell commands that run at agent lifecycle events, as opposed to skills that the model decides to use. The author shares a hook for AL projects that logs SessionStart, PreToolUse and PostToolUse events to a Markdown audit file, which records reads, commands and session context that Git history misses.

## Key points

- Hooks fire at lifecycle events without model judgment, while skills are loaded only when the model thinks they are relevant
- VS Code supports eight hook events, configured as JSON files that map events to commands
- The shared audit hook goes in the .github folder of an AL project and writes timestamp, session id, event, tool and detail rows to an audit log
- An environment variable in the hook config controls which events get logged
- Unlike Git diffs, the log captures file reads, terminal commands, uncommitted actions and session context

## Quotes

- "Hooks enable you to execute custom shell commands at key lifecycle points during agent sessions." (Explains the core mechanism of agent hooks for automation and control during AI-assisted coding.)

## Context

- Features: Agent Hooks lifecycle events, SessionStart hook, PreToolUse hook, PostToolUse hook, PreCompact hook, SubagentStart hook, SubagentStop hook, Stop hook

Source: Stefano Demiliani, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.
