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.
npx agentmods add commands/sourjya/kiro-rails/review-code-maintainabilitygit clone --depth 1 https://github.com/sourjya/kiro-railsWrote 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.
[](https://agentmods.dev/commands/sourjya/kiro-rails/review-code-maintainability)<a href="https://agentmods.dev/commands/sourjya/kiro-rails/review-code-maintainability"><img src="https://agentmods.dev/badge/commands/sourjya/kiro-rails/review-code-maintainability.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00031 | $0.03126 |
| Opus 5 | $0.00015 | $0.01563 |
| Sonnet 5 | $0.00006 | $0.00625 |
| Haiku 4.5 | $0.00003 | $0.00313 |
Grade A, and why
review-code-maintainability 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 6d ago.
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.
How it starts
The opening of the file, as written. The whole thing — 242 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Before scanning, read docs/decisions/ ADRs if they exist. Use documented architectural decisions to distinguish intentional patterns from accidental inconsistency. Do not flag documented exceptions as findings.
Act as a principal-level software engineer, software architect, and prompt-driven code review specialist.
Your task is to perform a comprehensive optimization, maintainability, and structural consistency review of this repository. Assess the codebase for redundancy, inconsistency, missed reuse opportunities, weak abstractions, and recurring engineering gaps, then produce a practical refactor plan that improves maintainability without altering business behavior.
Your mission is not just to find obvious duplicates. You must actively look for families of similar issues across the repository, including repeated patterns that appear with minor variations, inconsistent implementations of the same concern, and areas where the same engineering intent has been solved multiple different ways.
Activation Triggers
Run this review when:
- A feature or module is marked complete (feature-level scope)
- At the end of each development sprint (full codebase scope)
- When structural drift is suspected (inconsistent patterns emerging across modules)
- Before major refactoring work to identify priorities
- After multiple features have landed without intermediate review
Review Objectives
Focus on identifying:
- Duplicate or near-duplicate logic, copy-paste implementations, repeated validation, repeated condition chains, and redundant workflows.
- Opportunities to extract reusable abstractions such as helper functions, shared services, utility modules, base classes, adapters, hooks, middleware, or common components.
- Constants and values that should be centralized, including magic numbers, repeated strings, status labels, route names, error messages, configuration values, and environment-specific settings.
- Repeated types, DTOs, schemas, interfaces, models, and request/response structures that should be unified.
- Large or overloaded files, classes, and methods that should be decomposed for clarity, reuse, and testability.
- Weak module boundaries, poor folder organization, circular dependencies, and misplaced responsibilities.
- Repeated database, API, logging, exception-handling, and authorization patterns that should be standardized.
- Naming inconsistencies, dead code, stale abstractions, unused imports, and obsolete helpers.
- Clear, evidence-based performance improvements such as unnecessary recomputation, avoidable duplicate queries, inefficient loops, or repeated allocations. Do not recommend speculative micro-optimizations.
- Refactors that would materially improve testability and reduce future maintenance cost.
- Inconsistent error contract patterns, including multiple shapes for similar errors, repeated error translation logic, or mixed approaches to user-facing and internal error handling.
- Repeated parsing, serialization, transformation, mapping, or normalization logic that should be centralized.
- Inconsistent configuration access patterns, including direct environment reads scattered through the codebase, partially duplicated config loaders, or mixed defaulting behavior.
- Domain rules or business policies implemented in multiple places, especially if the same rule is enforced separately in controllers, services, validators, UI code, jobs, or database layers.
- Repeated control flow for retries, backoff, polling, idempotency, rate limiting, caching, batching, or pagination that should be standardized. Specifically flag: missing rate limiting on authentication or expensive endpoints implemented inconsistently across services, unbounded pagination parameters without a maximum cap enforced at a shared layer, and ReDoS-prone regex patterns applied to user input that should be centralized and reviewed for catastrophic backtracking.
- Frontend duplication such as repeated form logic, validation rules, loading states, empty states, error rendering, table behavior, modal patterns, or data-fetching orchestration.
- Backend duplication such as repeated controller scaffolding, request guards, service orchestration, repository access patterns, transaction handling, or response formatting.
- Logging and observability inconsistencies, including repeated log message templates, missing context propagation, mixed severity usage, or inconsistent metrics and tracing hooks. Specifically flag: security-relevant events that are not consistently logged across services (failed authentication, permission denials, admin actions, data exports), PII or sensitive data appearing in log output without masking, and missing correlation IDs or request context that would make incident investigation difficult.
- Test duplication, weak test structure, repeated fixture setup, brittle mocks, inconsistent factories, and missing opportunities for shared test utilities.
- Dependency hygiene issues such as duplicated utility libraries, overlapping packages, wrapper abstractions with little value, or modules coupled to too many concrete dependencies.
- Workflow and tooling duplication across scripts, CI pipelines, code generation, build steps, linting, formatting, and local developer commands.
- Public contract drift across API handlers, clients, SDKs, schemas, validators, and documentation.
- UI, API, and database naming drift where the same concept is represented with different terms, shapes, or statuses across layers.
- State management inconsistencies, including duplicated derived state, conflicting sources of truth, or business state spread across unrelated modules.
- File and module placement issues where code exists in technically functional but semantically wrong locations, making future navigation and ownership harder.
- Cross-cutting concerns implemented ad hoc, including auth, auditing, correlation IDs, feature flags, permissions, tenancy, localization, serialization, and response shaping.
- Unsafe or maintainability-harming patterns around async behavior, resource lifecycle, cleanup, event listeners, subscriptions, timers, worker jobs, or background processing.
- Areas where a change to one concept would currently require touching too many files, indicating poor cohesion or excessive coupling.
- Documentation drift inside the codebase, including misleading comments, stale READMEs, outdated examples, mismatched type comments, and code that no longer matches its stated intent.
- Places where introducing a shared abstraction would be premature, over-engineered, or harmful. Explicitly call these out so the refactor plan stays pragmatic.
- AI-generation artifacts: identify patterns typical of multi-session AI-generated code, including over-verbose boilerplate, redundant inline comments that merely restate what the code does, inconsistent naming conventions across files generated in different sessions, unnecessary abstraction layers that add indirection without reducing duplication, and structural inconsistencies that suggest the code was generated without awareness of adjacent modules.
- Test coverage delta: for every new module, service, utility, or Lambda handler identified in this review, flag whether corresponding unit or integration tests exist. Highlight untested public interfaces, untested business-critical paths, and any service boundaries that lack contract tests.
- Code commenting and documentation compliance: verify that all modules have file-level docstrings explaining purpose and architectural role, all classes have docstrings explaining responsibility and collaborators, all public methods have docstrings with purpose, args, returns, and raises, and all non-obvious private methods have justification comments. Flag files with zero or minimal documentation as HIGH severity - undocumented code is unmaintainable code. Reference the "Code Commenting Standards" rules in
CLAUDE.mdfor the full standard.
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.
- 6d ago First seen · 242 lines · 31 tokens per session scan A 101527b62715
review-code-maintainability is a command published in the GitHub repository sourjya/kiro-rails (9 stars, last pushed 1mo ago), licensed MIT. It adds 31 tokens to every session and 3,126 once invoked, about $0.0002 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.
Other commands, from other repositories
checklist
Generate a custom checklist for the current feature based on user requirements.
clarify
Identify underspecified areas in the current feature spec by asking up to 5 highly targeted clarification questions and encoding answers back into the spec.
specify
Create or update the feature specification from a natural language feature description.
analyze
Perform a non-destructive cross-artifact consistency and quality analysis across spec.md, plan.md, and tasks.md after task generation.
constitution
Create or update the project constitution from interactive or provided principle inputs.
converge
Assess the current codebase against the feature's spec, plan, and tasks, then append any remaining unbuilt work as new tasks to tasks.md so implement can complete it.