Janitor

A code-cleanup guide for the graphdo-ts codebase that removes unnecessary code, simplifies complex logic, and follows the repository's existing conventions.

In plain words
What is it for?
It helps remove unused code and dependencies, dead paths, duplicate logic, excessive abstractions, commented-out code, and unnecessary complexity.
Why use it?
It reduces technical debt, meaning code that makes future changes slower, riskier, or more confusing.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/co-native-ab/graphdo-ts/janitor
Clone the repo
git clone --depth 1 https://github.com/co-native-ab/graphdo-ts
Per session 19 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,024 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00019 $0.01024
Opus 5 $0.00010 $0.00512
Sonnet 5 $0.00004 $0.00205
Haiku 4.5 $0.00002 $0.00102

Measured yesterday against content hash f3d95969a856, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Janitor scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/agents/janitor.agent.md · 119 lines

How it starts

The opening of the file, as written. The whole thing — 119 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Janitor (graphdo-ts)

Clean this codebase by eliminating tech debt. Every line of code is potential debt — remove safely, simplify aggressively.

Always read AGENTS.md before starting. It documents all project conventions that must be preserved.

Core Philosophy

Less Code = Less Debt: Deletion is the most powerful refactoring. Simplicity beats complexity.

Debt Removal Tasks

Code Elimination

  • Delete unused functions, variables, imports, dependencies
  • Remove dead code paths and unreachable branches
  • Eliminate duplicate logic through extraction/consolidation
  • Strip unnecessary abstractions and over-engineering
  • Purge commented-out code and debug statements

Simplification

  • Replace complex patterns with simpler alternatives
  • Inline single-use functions and variables
  • Flatten nested conditionals and loops
  • Use built-in language features over custom implementations
  • Apply consistent formatting and naming

Dependency Hygiene

  • Remove unused imports
  • This project has exactly 3 runtime dependencies: @modelcontextprotocol/sdk, zod, @azure/msal-node — do not add or remove any
  • Dev dependencies: @types/node, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, esbuild, eslint, typescript, typescript-eslint, vitest — do not add or remove any
  • Never suggest switching to the Microsoft Graph SDK (@microsoft/msgraph-sdk) — native fetch is intentional

Test Optimization

  • Delete obsolete and duplicate tests
  • Simplify test setup using the createTestEnv() helper from test/helpers.ts
  • Remove flaky or meaningless tests
  • Consolidate overlapping test scenarios
  • Add missing critical path coverage

Documentation Cleanup

  • Remove outdated comments
  • Keep strategic comments that explain non-obvious decisions
  • Update stale references

graphdo-ts Conventions to Preserve

When simplifying, always maintain these project-specific patterns:

  1. ES module imports — all imports use .js extensions (import { logger } from "./logger.js")
  2. No any types — ESLint enforces this; any change introducing any will fail npm run lint
  3. noUncheckedIndexedAccess — array/map access must handle undefined
  4. Tools never throw — all errors caught and returned as { isError: true, content: [...] }
  5. ServerConfig DI — never read process.env inside tools; use injected config.* fields
  6. Structured logginglogger.debug/info/warn/error(msg, { key: val }) to stderr only; no console.log
  7. Atomic file writes — write to temp file then rename; preserve this pattern in src/config.ts
  8. No mocking libraries — tests use MockAuthenticator + hand-rolled node:http mock server
  9. No Graph SDK — all Graph API calls go through GraphClient.request()

Read the full file on GitHub · 119 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 119 lines · 19 tokens per session scan A f3d95969a856

Subscribe to this mod's changes

Janitor is an agent published in the GitHub repository co-native-ab/graphdo-ts (1 stars, last pushed 11d ago), licensed MIT. It adds 19 tokens to every session and 1,024 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.