clean-code

clean-code is an agent for Claude Code from Ramilito/kubectl.nvim. It costs 28 tokens per session (1,533 once invoked), scanned A, original, Apache-2.0.

A reference for writing readable, maintainable code through choices about functions, names, complexity, and program structure. It explains how to keep each function focused and easier for people to understand.

In plain words
What is it for?
Use it when deciding how to split functions, choose names, limit parameters, and organize code into clearer units.
Why use it?
It helps reduce the mental effort needed to read and change code, especially when functions mix unrelated responsibilities or become too complex.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter.

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/ramilito/kubectl.nvim/clean-code
Clone the repo
git clone --depth 1 https://github.com/Ramilito/kubectl.nvim

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for clean-code

README.md
[![agentmods](https://agentmods.dev/badge/agents/ramilito/kubectl.nvim/clean-code.svg)](https://agentmods.dev/agents/ramilito/kubectl.nvim/clean-code)
Your own site
<a href="https://agentmods.dev/agents/ramilito/kubectl.nvim/clean-code"><img src="https://agentmods.dev/badge/agents/ramilito/kubectl.nvim/clean-code.svg" alt="Measured on agentmods" height="20"></a>
Per session 28 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,533 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.1 $0.00028 $0.01533
Opus 5 $0.00014 $0.00766
Sonnet 5 $0.00006 $0.00307
Haiku 4.5 $0.00003 $0.00153

Measured yesterday against content hash 73b5bdbfa651, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

clean-code 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.

.claude/agents/clean-code.md · 246 lines

How it starts

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

Clean Code Principles

Guidance for maintaining clean, readable code that respects human cognitive limits.

Core Principle: Limited Working Memory

Humans can hold approximately 4-7 items in working memory at once. Code must be written with this constraint in mind. Every function, module, and abstraction should minimize the mental load required to understand it.

Function Design

Keep Functions Small and Focused

A function should do one thing and fit in your head:

  • Max 20-30 lines as a soft guideline
  • Max 3-4 parameters - more indicates the function does too much
  • Single level of abstraction - don't mix high-level logic with low-level details
-- BAD: Mixed abstraction levels, too much happening
function process_pod(pod)
  local name = pod.metadata.name
  local ns = pod.metadata.namespace
  local status = pod.status.phase
  if status == "Running" then
    local containers = pod.spec.containers
    for _, c in ipairs(containers) do
      -- 50 more lines of container processing...
    end
  end
  -- format output, handle errors, update state...
end

-- GOOD: Each function handles one concern
function process_pod(pod)
  local info = extract_pod_info(pod)
  if is_running(info) then
    process_containers(pod.spec.containers)
  end
  return format_output(info)
end

Descriptive Names Over Comments

Names should reveal intent. If you need a comment to explain what code does, rename it instead:

// BAD
let t = 86400; // seconds in a day

// GOOD
let seconds_per_day = 86400;

// BAD
fn proc(d: &Data) -> Result  // processes the data

// GOOD
fn validate_and_transform_resource(resource: &Resource) -> Result

Early Returns to Reduce Nesting

Deep nesting forces the reader to track multiple conditions. Use early returns:

-- BAD: Reader must track 3 levels of conditions
function handle_request(req)
  if req then
    if req.valid then
      if req.authorized then
        -- actual logic here, 3 levels deep
      end
    end
  end
end

-- GOOD: Flat structure, exit early
function handle_request(req)
  if not req then return nil end
  if not req.valid then return nil, "invalid" end
  if not req.authorized then return nil, "unauthorized" end

  -- actual logic here, at top level
end

Read the full file on GitHub · 246 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 · 246 lines · 28 tokens per session scan A 73b5bdbfa651

Subscribe to this mod's changes

clean-code is an agent published in the GitHub repository Ramilito/kubectl.nvim (537 stars, last pushed 22d ago), licensed Apache-2.0. It adds 28 tokens to every session and 1,533 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-09-04.