Building a Zero-Dependency Client Codebase Auditor & 3-Page Native PDF Generator in TypeScript (CLI + Official MCP Server)

2026-11-29来源 dev.toEnglish
Building a Zero-Dependency Client Codebase Auditor & 3-Page Native PDF Generator in TypeScript (CLI + Official MCP Server)

If you freelance or run a small engineering studio, you know the pain of milestone handovers and paid codebase audits.

A 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.

Cloud SaaS scanners don't solve this well either: many clients under NDA explicitly forbid uploading proprietary source code to third-party servers.

AuditDeck CLI & 3-Page Client Handover PDF Preview

So I built 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.

Here are the four most interesting engineering problems I solved while building it (and shipping it to the Official MCP Registry with GitHub Actions OIDC).

1. Secret Scanning Without Ever Leaking Raw Secrets Into Reports

A 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.

In AuditDeck's security scanner, every pattern match is masked at match time before it ever enters an audit finding object:

function maskSecret(raw: string): string { const trimmed = raw.trim(); if (trimmed.length <= 8) return "****"; return `${trimmed.slice(0, 4)}...${trimmed.slice(-4)}`; } 

We also:

  • Skip binary files, node_modules, .git, build artifacts, and files over 512 KB so scans finish in milliseconds even on monorepos.
  • Distinguish live .env files present in the working tree (a critical handover hazard) from safe .env.example templates.
  • Scan specifically for high-signal live credential prefixes (AWS 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.

2. Computing Git Bus-Factor Safely (Zero Shell Injection)

To score maintainability and handover risk, AuditDeck inspects commit history, active author count, recent velocity, and monolithic source hotspots.

One 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.

Instead, every Git probe uses execFileSync("git", [...args], { cwd: repoPath }) with a strict timeout and clean fallback when scanning a non-Git archive:

import { execFileSync } from "node:child_process"; function runGit(repoPath: string, args: string[]): string | null { try { return execFileSync("git", args, { cwd: repoPath, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5000, }).trim(); } catch { return null; } } 

From 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).

3. Generating a Multi-Page Client PDF 1.4 Without Puppeteer or Chromium

Most 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.

A 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:

  • Zero runtime dependencies (literally 0 entries in dependencies in package.json).
  • Deterministic byte offsets computed directly with Buffer.byteLength(..., "latin1") so xref is valid across macOS Preview, Chrome, Firefox, Adobe Acrobat, and pdftotext.
  • ASCII-safe text escaping (\, (, )) and strict line-wrapping so long file paths never overflow the right margin.

You can inspect an actual 3-page PDF generated directly by this zero-dep engine here:
👉 View Live 3-Page Sample Pro PDF

4. Shipping a Zero-Dep Stdio MCP Server to the Official MCP Registry via GitHub Actions OIDC

Running 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.

Because 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.

To publish to the Official MCP Registry (io.github.danielneuron/auditdeck) automatically on every GitHub Release with zero long-lived API secrets:

  1. Add the MCP OCI label to your Dockerfile:
 LABEL io.modelcontextprotocol.server.name="io.github.danielneuron/auditdeck" 
  1. Push the container to ghcr.io in GitHub Actions and authenticate mcp-publisher via GitHub OIDC (id-token: write):
 mcp-publisher login github-oidc mcp-publisher publish 

Both io.github.danielneuron/auditdeck and its companion AI billing tool io.github.danielneuron/promptbill are now live on the Official MCP Registry and indexed on Glama (83% Discovery Score, A Server Coherence).

Try AuditDeck in 5 Seconds

# Preview with realistic demo data npx github:danielneuron/auditdeck scan --demo npx github:danielneuron/auditdeck pdf --demo --client "Acme FinTech Pty Ltd" --out handover.pdf # Or add straight to Claude Code as a local MCP server claude mcp add auditdeck -- npx -y github:danielneuron/auditdeck mcp 

The 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 together with PromptBill Pro to save $9).

What 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!

原文:https://www.a8q9.cn/en/article/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator-i-d09a4c.html

相关文章