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.
Demo
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:
- Git hook fires - on commit or push,
agent-watch runis triggered automatically. - Smart filter checks - skips entirely if only docs, configs, or lock files changed.
- Sessions extracted - pulls latest 3 unprocessed sessions from Claude Code, Copilot Chat, and Copilot CLI.
Patterns summarized - Copilot CLI distills each session into actionable conventions.
Atomic update - a single
copilot --yolocommand updates all agent files at once with combined context
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 summarize sessions, understand code patterns, or update agent files, it shells out to Copilot CLI with a carefully crafted prompt. The final update uses a single copilot --yolo command that reads and updates all agent files atomically in one pass. 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, Copilot CLI analyzes your codebase and generates a tailored starting file.
2) Updating Agent Files on Every Commit
The core use. On each git hook trigger, Agent Watch gathers context (commit message, changed files, diff stats, chat sessions) and asks Copilot CLI to intelligently merge new patterns into each managed agent file — or skip if nothing meaningful changed.
3) Extracting Chat Session History
Agent Watch discovers your past Copilot conversations, filters to the current project, and asks Copilot CLI to summarize them. These insights feed into the agent file updates above.
Get Started
1.Installation
Global installation(Highly Recommended)
npm install -g agent-watch
As a dev dependency
npm install -D agent-watch
# or
pnpm add -D agent-watch
Run directly without installation:
npx agent-watch init
2. Initialize your project
cd your-project
agent-watch init
Before vs. After using agent-watch
Before agent-watch:-
You're building a Node.js backend. Over the course of a sprint:
Monday: You set up Express with a centralized error handler middleware.
Tuesday: You adopt Drizzle ORM and write all queries through a repository pattern
Wednesday: You add JWT auth with refresh tokens and role-based access
Thursday: A teammate asks Cursor to write a new endpoint — it uses raw SQL,
try/catchin every route, and rolls its own auth check
⛔PROBLEM⛔: Your AI agent files are stuck in the past. Every assistant on the team is guessing instead of following what you've already established.
After agent-watch:-
Every commit automatically updates your agent instruction files:
Monday commit: "Use centralized error handler — never catch errors in individual routes"
Tuesday commit: "Use Drizzle ORM with repository pattern — no raw SQL"
Wednesday commit: "Auth uses JWT with refresh tokens — use
requireRole()middleware"Thursday commit: Teammate's Cursor already knows all of this. It generates the endpoint correctly on the first try.
RESULT: Conventions are captured as they emerge, not weeks later when someone remembers to update a config file. Every AI assistant on your team stays aligned — automatically. ✅
Challenges Faced(and how Copilot CLI helped)
Git hooks without breaking existing setups
Teams use Lefthook, Husky, or raw hooks. Copilot CLI helped us design marker-based injection that works alongside any existing setup and is safe to re-run.Discovering chat sessions across three AI tools
Claude Code, Copilot Chat, and Copilot CLI all store sessions in different locations and formats. We use Copilot CLI to summarize sessions from all three into a unified format.Combining everything into one coherent update
Sessions could easily produce noisy, duplicate updates.copilot --yolocommand takes all summaries and file paths, then updates every agent file automically in one pass.
The Takeaway: Agent Watch is plumbing. Every intelligent decision is a Copilot CLI call at the right moment with the right context.
Repository
surnr
/
agent-watch
CLI tool that uses git hooks to keep your AI agent configuration files in sync with your codebase
Agent Watch
Keep your AI agents in sync with your evolving codebase—automatically.
Agent Watch is a CLI tool that captures knowledge from your development workflow—git commits, code changes, and AI chat sessions—and intelligently updates your AI agent configuration files. Stop manually copying patterns from chat sessions. Stop forgetting to update CLAUDE.md or Copilot instructions. Let agent-watch learn from your work and keep your AI agents informed.
Why Agent Watch?
The Problem
You're having productive conversations with Claude Code, GitHub Copilot, and other AI assistants. They help you establish patterns, conventions, and best practices. But this knowledge stays trapped in chat history. Your agent configuration files (CLAUDE.md, copilot-instructions.md, etc.) become outdated within days.
Result: Your AI assistants keep making the same mistakes. They forget your team's conventions. You waste time repeating yourself.
The Solution
Agent Watch automatically:
- ✅ Extracts patterns from your Claude Code, Copilot Chat, and Copilot CLI sessions
- ✅…

Top comments (13)
whoa! this is so practical 🔥
all I would suggest is adding the demo in the github repo as well :)
Sure, Thank you ❤️
💖🔥
Awesome...All in one😍😍😍
Cool project🙌 the auto-sync concept solves a real pain point.
thank you ☺️
That is super Interesting buddy thanks for making that tool . It is much needed for some user
Wow Surender ser! cool one 🔥
Wow that a great project!!
thanks 😊
Let's go 🚀
Amazing boiiii Surendar boii on top!!🔥
Let's finally found someone who solved this issuee!!, let's go