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

> Source: <https://dev.to/danielneuron/building-a-zero-dependency-client-codebase-auditor-3-page-native-pdf-generator-in-typescript-cli-36fh>
> Published: 2026-11-29 00:02:40+00:00

**Recommendation:** 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.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

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.

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

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

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:

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

We also:

`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.
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:

``` js
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`).

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:

`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.
You can inspect an actual 3-page PDF generated directly by this zero-dep engine here:

👉 **View Live 3-Page Sample Pro PDF**

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

`Dockerfile`:

```
   LABEL io.modelcontextprotocol.server.name="io.github.danielneuron/auditdeck"
```

`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`](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).

```
# 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**](https://buy.polar.sh/polar_cl_UVB0LzPKWpKwgE16tHFYvTlwOpsRzQN6IyYGT4Y87zn) together with [** PromptBill Pro**](https://github.com/danielneuron/promptbill) 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!
