Custom Repo Guardrails and AGENTS.md for Solo and AI-Assisted Maintenance
Keeping a personal codebase clean months later—whether it's future-me or a coding agent making the next pull request.

It's easy to keep a repository clean on day one. The real challenge is six months later—when you're making a quick update on a weekend, or pairing with an AI coding agent that doesn't remember why you structured things a certain way. 🤖
On reggiepangilinan.com, I stopped relying on memory and turned my repo conventions into executable guardrails that run on every commit and pull request.
🎯 1. One Source of Truth: SITE_CONFIG
Every piece of site identity—domain, contact email, author name, social URLs, default Open Graph image paths, and robots.txt rules—lives in src/config/site.ts.
Instead of hoping nobody hardcodes reggiepangilinan.com or an email address inside a component, SITE_CONFIG.guards defines the exact patterns that should always be imported rather than duplicated.

🚨 2. What npm run guards Actually Checks
One command (npm run guards) chains four lightweight Node scripts together in both Husky pre-commit hooks and .github/workflows/ci.yml:
Pattern validation (
scripts/validate-guard-patterns.js): Confirms every guard pattern maps cleanly to a realSITE_CONFIGproperty.Auto-synced config (
scripts/sync-guard-config.js): Regeneratesscripts/guard-config.jsdirectly fromsrc/config/site.tsso scanner rules never drift.Hardcoded value scanner (
scripts/check-hardcoded-values.js): Scans the codebase and fails CI if personal domains, emails, social handles, or image paths are hardcoded outside explicitly excluded folders (docs/,drafts/,published/).Documentation link checker (
scripts/check-doc-references.js): Verifies every Markdown guide underdocs/is indexed indocs/README.mdwith zero broken links or orphaned files.
🔑 3. Zero-Secret Local & CI Builds
One guardrail that pays off every single week is making sure the site builds cleanly with zero secrets.
In src/lib/contentful.ts, if CONTENTFUL_SPACE_ID or CONTENTFUL_ACCESS_TOKEN aren't set, the client initializes as null and data fetchers return empty lists gracefully. That means GitHub Actions CI runs npm run lint, npm run type-check, npm run guards, and npm run build on every pull request without needing CMS credentials at all.
📋 4. Writing AGENTS.md for Human + AI Collaboration
Since I regularly pair with coding agents to upgrade dependencies, build features, and draft posts, I added AGENTS.md at the repo root.
It acts like a concise engineering handbook:
Component folder conventions (
ComponentName/ComponentName.tsx,.module.css,index.tsx)Rendering boundaries (SSG vs. dynamic
/blogvs. 24h ISR/blog/[slug])Security invariants (never logging secrets in API routes)
Blog writing guidelines (per-post
drafts/<slug>/folders,RichTextRendererconstraints, clickable GitHub links)The exact verification commands required before opening a PR
The best part? Good guardrails for AI agents are just good engineering hygiene for humans too. 🙌
✨ Wrapping Up
You don't need a massive platform team to get the benefits of automated governance. A handful of small Node scripts, zero-secret builds, and a clear AGENTS.md keep a personal repo fast to evolve—and hard to accidentally break.
You can explore all the guard scripts under scripts/ and AGENTS.md on GitHub.
Related Posts
Adding AI-Powered Blog Search with Google Gemini in Next.js
How we added an intelligent, Gemini-powered search bar to a Next.js + Contentful blog—covering AI basics for non-specialists, why hybrid search beat Google Search Grounding and Vertex AI Search, real-world free-tier traffic estimates, and built-in cost guardrails.
Generative Engine Optimization (GEO) in Next.js 16: llms.txt, RSS, JSON-LD & Crawler Access
A plain-English primer on Generative Engine Optimization (GEO) plus six concrete Next.js 16 upgrades: dynamic /llms.txt, /rss.xml, Person & WebSite JSON-LD, explicit AI bot rules, and non-JS visibility.
Running a Full Next.js Blog on Free Tiers: A Contentful + Netlify Case Study
A data-backed case study breaking down Contentful Free, Netlify Free, and GitHub Free quotas (at the time of this writing), with real math on how many visitors, blog posts, and images a personal site can serve before ever paying a cent for infrastructure.