{"slug": "building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator", "title": "Building a Zero-Dependency Client Codebase Auditor & 3-Page Native PDF Generator in TypeScript (CLI + Official MCP Server)", "summary": "A developer built AuditDeck, an MIT-licensed, zero-dependency TypeScript CLI and Model Context Protocol server that audits local Git repositories across five technical pillars and renders a multi-page client handover PDF in under five seconds without Puppeteer or Chromium. The tool masks secrets at match time, uses execFileSync with argument arrays to avoid shell injection, flags single-author bus-factor risk from git shortlog, and generates PDFs via raw PDF 1.4 vector operators, with the project published to the Official MCP Registry using GitHub Actions OIDC.", "body_md": "If you freelance or run a small engineering studio, you know the pain of **milestone handovers** and **paid codebase audits**.\n\nA client pays you to audit a legacy repo before an acquisition, a seed round, or a handoff to an internal team. You spend 45 minutes inspecting the repo — spotting leaked `.env` files, missing lockfiles, a single-author Git bus factor of 1, a 1,800-line God file, and zero CI checks — and then you burn **3 to 5 hours** formatting a Notion doc or Google Slides deck so a non-technical founder or CTO can actually read it.\n\nCloud SaaS scanners don't solve this well either: many clients under NDA explicitly forbid uploading proprietary source code to third-party servers.\n\nSo I built [**AuditDeck**](https://github.com/danielneuron/auditdeck) — a **100% local-first, zero-dependency, MIT open-core CLI & Model Context Protocol (MCP) server** that audits any local Git repository across 5 technical pillars and renders a multi-page **Client Handover PDF** in under 5 seconds, without Puppeteer, Chromium, or a single byte leaving your laptop.\n\nHere are the four most interesting engineering problems I solved while building it (and shipping it to the **Official MCP Registry** with GitHub Actions OIDC).\n\nA surprising number of lightweight scanners detect an AWS or Stripe key and then echo the entire offending line straight into a JSON or Markdown report. If you email that handover PDF to a client executive or drop it in Slack, **your audit report just became a credential leak**.\n\nIn AuditDeck's security scanner, every pattern match is masked **at match time** before it ever enters an audit finding object:\n\n``` js\nfunction maskSecret(raw: string): string {\n  const trimmed = raw.trim();\n  if (trimmed.length <= 8) return \"****\";\n  return `${trimmed.slice(0, 4)}...${trimmed.slice(-4)}`;\n}\n```\n\nWe also:\n\n`node_modules`, `.git`, build artifacts, and files over 512 KB so scans finish in milliseconds even on monorepos.`.env` files present in the working tree (a critical handover hazard) from safe `.env.example` templates.`AKIA...`, Stripe `sk_live_...`, GitHub `ghp_...` / `github_pat_...`, OpenAI/Anthropic/Google API keys, PEM private key blocks, and embedded DB connection passwords) so false positives stay low.\nTo score maintainability and handover risk, AuditDeck inspects commit history, active author count, recent velocity, and monolithic source hotspots.\n\nOne rule I stick to in local dev tools: **never pass user paths to `execSync` with string interpolation**. Even a repo folder with spaces or `$(...)` in its name will break or execute unintended shell commands.\n\nInstead, every Git probe uses `execFileSync(\"git\", [...args], { cwd: repoPath })` with a strict timeout and clean fallback when scanning a non-Git archive:\n\n``` js\nimport { execFileSync } from \"node:child_process\";\n\nfunction runGit(repoPath: string, args: string[]): string | null {\n  try {\n    return execFileSync(\"git\", args, {\n      cwd: repoPath,\n      encoding: \"utf8\",\n      stdio: [\"ignore\", \"pipe\", \"ignore\"],\n      timeout: 5000,\n    }).trim();\n  } catch {\n    return null;\n  }\n}\n```\n\nFrom `git shortlog -sn --all` we compute contributor concentration: if one developer authored `>= 85%` of commits in a non-trivial codebase, AuditDeck flags a **Single-Author Bus-Factor Risk** and weights it into the 0–100 Executive Health Score (`A`–` F`).\n\nMost Node.js PDF tools either bundle a 170 MB headless Chromium binary or require heavy native bindings. For a CLI that people invoke via `npx` or inside a tiny Docker MCP container, that's a non-starter.\n\nA crisp business report — typography hierarchy, navy executive banner, color-coded pillar progress bars, severity pills (`CRITICAL` / `HIGH` / `MEDIUM`), a structured findings register, and a Page 3 30-Day Remediation Roadmap + Client Sign-Off block — only needs raw **PDF 1.4 vector operators** (`rg`, `re`, `f`, `BT/ET`, `Tf`, `Td`, `Tj`) and a clean cross-reference (` xref`) table:\n\n`0` entries in `dependencies` in `package.json`).` Buffer.byteLength(..., \"latin1\")` so `xref` is valid across macOS Preview, Chrome, Firefox, Adobe Acrobat, and `pdftotext`.`\\`, `(`, `)`) and strict line-wrapping so long file paths never overflow the right margin.\nYou can inspect an actual 3-page PDF generated directly by this zero-dep engine here:\n\n👉 **View Live 3-Page Sample Pro PDF**\n\nRunning AuditDeck from the terminal (`npx github:danielneuron/auditdeck scan .`) is great, but even better is letting **Claude Code**, **Cursor**, **Cline**, or **Windsurf** audit a repo mid-conversation and generate the client handover PDF directly.\n\nBecause MCP over `stdio` is newline-delimited JSON-RPC 2.0, implementing protocol `2025-11-25` cleanly with **server `instructions`**, **4 annotated tools** (` readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`), and **2 guided MCP prompts** (` client-handover-audit`, `pre-release-security-check`) took ~280 lines of zero-dep TypeScript.\n\nTo publish to the **Official MCP Registry** (`io.github.danielneuron/auditdeck`) automatically on every GitHub Release with **zero long-lived API secrets**:\n\n`Dockerfile`:\n\n```\n   LABEL io.modelcontextprotocol.server.name=\"io.github.danielneuron/auditdeck\"\n```\n\n`ghcr.io` in GitHub Actions and authenticate `mcp-publisher` via GitHub OIDC (`id-token: write`):\n\n```\n   mcp-publisher login github-oidc\n   mcp-publisher publish\n```\n\nBoth [`io.github.danielneuron/auditdeck`](https://registry.modelcontextprotocol.io/v0.1/servers/io.github.danielneuron%2Fauditdeck/versions) and its companion AI billing tool [`io.github.danielneuron/promptbill`](https://registry.modelcontextprotocol.io/v0.1/servers/io.github.danielneuron%2Fpromptbill/versions) are now live on the **Official MCP Registry** and indexed on **Glama** (`83%` Discovery Score, `A` Server Coherence).\n\n```\n# Preview with realistic demo data\nnpx github:danielneuron/auditdeck scan --demo\nnpx github:danielneuron/auditdeck pdf --demo --client \"Acme FinTech Pty Ltd\" --out handover.pdf\n\n# Or add straight to Claude Code as a local MCP server\nclaude mcp add auditdeck -- npx -y github:danielneuron/auditdeck mcp\n```\n\nThe full 5-pillar scanner, masked secret detector, Markdown/JSON exports, 2-page PDF preview, and full local MCP server are **100% free & MIT open-source**. If you deliver paid client audits or handovers and want white-label branding, Page 3 (30-Day Remediation Roadmap + Client Sign-Off block), formula-safe Jira/Linear CSV export, or multi-repo portfolio rollups (`auditdeck merge`), optional one-time licenses are available via Polar.sh (`$29` Pro / `$69` Agency — or grab the [**`$39` Dev CLI & MCP Pro Bundle**](https://buy.polar.sh/polar_cl_UVB0LzPKWpKwgE16tHFYvTlwOpsRzQN6IyYGT4Y87zn) together with [** PromptBill Pro**](https://github.com/danielneuron/promptbill) to save `$9`).\n\nWhat checks would be most valuable to add next for client codebase handovers — **Docker/container hardening**, **Terraform/IaC drift**, or **database migration safety**? Drop a comment below!", "url": "https://wpnews.pro/news/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator", "canonical_source": "https://dev.to/danielneuron/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator-in-typescript-cli-36fh", "published_at": "2026-11-29 00:02:40+00:00", "updated_at": "2026-11-29 00:13:54.135089+00:00", "lang": "en", "topics": ["ai-tools", "ai-agents", "agent-protocols", "developer-tools", "ai-safety"], "entities": ["AuditDeck", "Model Context Protocol", "Official MCP Registry", "GitHub Actions", "GitHub", "TypeScript"], "also_reported_by": [], "takeaway": "Mask secrets at match time (first four and last four characters) before they enter any finding object, and call Git via execFileSync with an argument array and a 5-second timeout instead of interpolating paths into execSync.", "recommendation": {"advice": "Mask credentials at match time before they enter report objects, and run Git probes with execFileSync argument arrays plus timeouts so repo paths can never inject shell commands.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator", "markdown": "https://wpnews.pro/news/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator.md", "text": "https://wpnews.pro/news/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator.txt", "jsonld": "https://wpnews.pro/news/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator.jsonld"}}