This is a group submission for the GitHub Copilot CLI Challenge
Introduction
"Auto-sync your AI instructions with every commit using agent-watch", a git hook that reads your commits and conversations, then uses AI to keep all your agent instruction files current — so your AI tools always know what your codebase looks like today.
What We Built
AI coding assistants like Claude Code, GitHub Copilot, Cursor, Windsurf and Cline, each read an instruction file(CLAUDE.md, .cursorrules, copilot-instructions.md, etc.) to understand your project's conventions, architecture, and rules.
But here's the thing: Your codebase changes every day. Those instruction files don't.
You could refactor a module, swap a library or change an API pattern, yet your AI agent is still giving advice based on stale instructions. You are either manually updating those files (tedious) or you don't (getting worse AI suggestions over time).
What Agent Watch Does
It plugs into your git workflow and automatically updates your AI instruction files after every commit or push. No manual effort.
Here's the flow:
- You commit code as usual.
- A git hook fires and gathers context — what files changed, commit messages, diff stats, even your recent Copilot chat history.
- It sends that context to GitHub Copilot CLI with a smart prompt.
- Copilot decides whether your agent files need updating — if yes, it rewrites them; if not, it skips.
That's it. Your AI tools always have fresh, accurate instructions.
What This Means for You as a Developer
- Your AI assistants get smarter over time — they learn as your codebase evolves, not just when you remember to update a config file
- Zero maintenance overhead — you never touch those instruction files manually again.
- Works with whatever AI tool you use — one tool keeps Claude, Copilot, Cursor, Windsurf, and Cline all in sync.
- Doesn't slow you down — smart filtering skips running when you only change docs, lock files, or configs.
- Fits your existing workflow — supports Lefthook, Husky, or plain git hooks. Just
agent-watch initand forget about it.
The Bigger Picture
AI coding assistants are only as good as the context they have. Agent Watch closes the gap between what your codebase actually looks like and what your AI tools think it looks like. It turns static instruction files into living documents that evolve with your code.
It's a small tool that solves a real, growing pain point — and as AI-assisted development becomes the norm, keeping agent context fresh isn't optional anymore. It's table stakes.
How GitHub Copilot CLI is leveraged for this tool
Agent Watch doesn't contain any AI logic itself. It's purely plumbing — git hooks, file detection, context gathering, and state tracking. All the intelligence is delegated to GitHub Copilot CLI. Every time Agent Watch needs to understand code, generate content, or decide whether an agent file needs updating, it shells out to copilot -p with a carefully crafted prompt and uses the response. Copilot CLI is the brain; Agent Watch is the nervous system that triggers it at the right time with the right context.
3 Distinct Uses of Copilot CLI
1) Creating Missing Agent Files
During agent-watch init, if a selected agent file doesn't exist yet, Copilot CLI creates it. Two paths:
- For
.github/copilot-instructions.md— Runscopilot init(Copilot's built-in scaffolding) - For everything else (
CLAUDE.md,.cursorrules, etc.) — Runs:
copilot -p "Create a <filename> file for this project. Analyze the codebase..." --allow-all-tools -s
Copilot reads the codebase and generates a tailored starting file.
2) Updating Agent Files on Every Commit
This is the core use. On each git hook trigger, Agent Watch builds a context string (commit message, changed files, diff stats, chat sessions) and for each managed agent file calls:
copilot -p "<prompt with current file content + recent context>" -s
The prompt tells Copilot to merge new patterns into the existing document and output the complete updated file — or exactly NO_UPDATE if nothing meaningful changed. Timeout is 90 seconds per file.
3) Extracting Chat Session History
Agent Watch mines your past Copilot conversations for insights:
copilot --resume <sessionId> -p "List every user request and your response..." -s
It discovers sessions from ~/.copilot/session-state/, filters to the current project, resumes each unprocessed session, and asks Copilot to summarize conversations in a structured USER: ... | AGENT: ...format. This context feeds into the update prompt above.
Installation
Global installation
npm install -g agent-watch
As a dev dependency
npm install -D agent-watch
or
pnpm add -D agent-watch
Or run directly without installation:
npx agent-watch init
Repository

surnr
/
agent-watch
CLI tool that uses git hooks to keep your AI agent configuration files in sync with your codebase
Agent Watch
CLI tool that uses git hooks to keep your AI agent configuration files in sync with your codebase. It watches for commits or pushes, gathers context from git changes and chat sessions, and automatically updates your agent files.
Install
Global installation (recommended for CLI usage):
npm install -g agent-watchAs a dev dependency (for team consistency):
npm install -D agent-watch
# or
pnpm add -D agent-watchOr run directly without installation:
npx agent-watch initQuick start
cd your-project
agent-watch initThe init command walks you through an interactive setup:
Select agent files - auto-detects existing files and lets you pick which ones to manage (space to toggle, enter to confirm)
Git context - choose whether to use commit messages and chat sessions when updating files
Hook trigger - pick when to run: aftergit commitor beforegit push
AI agents - select which agent integrations to enable…
SOCIAL SHARE CARD GENERATOR