agentleFS
reliable-coding-agentsreliable-coding-agents/reliable-python/skills/using-power-of-ten/SKILL.md

using-power-of-ten

Skill1 starsChanged 2 months agoMITView on GitHub

Apply NASA/JPL's Power of Ten rules and the Refactoring.Guru code-smell catalog while writing, changing, reviewing, or refactoring Python. Use for any Python implementation task in a project that has adopted strict reliability or maintainability guardrails.

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 10 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈10

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat these rules as constraints while designing and editing code, then verify the finished diff.

    line 8
  2. Distinctive:

    Treat a code smell as a design signal, not an automatic defect.

    line 20
  3. Very specific:

    Keep control flow simple. Do not use direct or indirect recursion.

    line 27
  4. Distinctive:

    Keep each function at about 60 physical lines or fewer.

    line 34
  5. Very specific:

    Avoid behavior hidden from static analysis: eval, exec, dynamic imports, runtime code generation, and unjustified attribute magic.

    line 43
  6. Distinctive:

    Keep indirection shallow. Replace long message chains and opaque callback dispatch with named, typed boundaries.

    line 45
  7. Distinctive:

    Run the project's strictest compiler, linter, type checker, and tests.

    line 47
  8. Very specific:

    Before editing, inspect repository guidance and existing validation commands.

    line 63
  9. Distinctive:

    Prefer the smallest design that satisfies the requirement.

    line 73
  10. Distinctive:

    Never hide a violation. If compliance is infeasible, explain the tradeoff and obtain an explicit decision.

    line 77
  11. Distinctive:

    Run its bundled Python checker on changed Python files.

    line 85
  12. Distinctive:

    Run the repository's relevant lint, type-check, and test commands.

    line 86
  13. Distinctive:

    Use a narrow suppression only for a confirmed false positive:

    line 90

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Reliable Python

Treat these rules as constraints while designing and editing code, then verify the finished diff. Optimize for code whose resource use, control flow, and failure modes a reviewer can enumerate.

Scope and honesty

Apply an intent-preserving Python profile of Gerard Holzmann's C-oriented Power of Ten rules. Do not describe the result as literal C compliance, NASA certification, or proof of safety. Rules 3, 8, and 9 require language-specific translation; read the rule mapping whenever they are relevant.

Treat a code smell as a design signal, not an automatic defect. Confirm a concrete cost—harder change, hidden failure, duplication, or excess coupling— before refactoring. Read the smell catalog for any structural change or review.

Working rules

  1. Keep control flow simple. Do not use direct or indirect recursion. Do not use exceptions for ordinary branching. Keep block nesting at four levels or fewer; load limiting-nesting when a function goes deeper.
  2. Give every terminating loop a preset upper bound. Make an intentionally non-terminating service loop explicit and keep bounded work inside it.
  3. Bound runtime growth. Put ceilings on collections, queues, caches, input sizes, retries, concurrency, and other resources.
  4. Keep each function at about 60 physical lines or fewer. Extract coherent units instead of compressing statements.
  5. Maintain at least two meaningful, side-effect-free defensive checks per function on average. Prefer explicit guard-and-raise logic for production invariants because Python can remove assert statements with -O.
  6. Declare and mutate data in the narrowest useful scope. Avoid mutable globals, global, and mutable default arguments.
  7. Validate public-boundary parameters and handle fallible results. Never swallow an error with except: pass or discard a status accidentally.
  8. Avoid behavior hidden from static analysis: eval, exec, dynamic imports, runtime code generation, and unjustified attribute magic.
  9. Keep indirection shallow. Replace long message chains and opaque callback dispatch with named, typed boundaries.
  10. Run the project's strictest compiler, linter, type checker, and tests. End with zero warnings in the changed scope; fix confusing code instead of silencing tools without a written reason.

Documentation convention

This is a project convention, not one of Holzmann's ten rules. Document every public module, class, and function in this project's configured convention, which defaults to NumPy style; it carries per-parameter types, defaults, and constraints that a reader needs to enumerate a function's inputs. Google and reST are supported alternates, set per project. The active convention is stated at the end of this policy. Load writing-docstrings before writing or restructuring a docstring.

Workflow

Before editing, inspect repository guidance and existing validation commands. Load bounded-loops before implementing retry, polling, pagination, convergence, stream-consumption, or other variable-length loops. Load writing-maintainable-python for entry points, public type contracts, function decomposition, or comprehension choices. Load applying-solid-principles for class hierarchies, protocols, interfaces, or dependency boundaries.

While editing:

  • Prefer the smallest design that satisfies the requirement.
  • Preserve behavior unless the user requests a behavior change.
  • Address smells in touched code when the benefit is concrete and the change stays in scope; do not launch unrelated cleanup.
  • Never hide a violation. If compliance is infeasible, explain the tradeoff and obtain an explicit decision.

Before finishing:

  1. Inspect the complete diff and trace affected callers, tests, and failure paths.
  2. Invoke review-code-quality for a structured semantic review.
  3. Run its bundled Python checker on changed Python files.
  4. Run the repository's relevant lint, type-check, and test commands.
  5. Fix confirmed findings. Report remaining exceptions with rule or smell ID, evidence, impact, and rationale.

Use a narrow suppression only for a confirmed false positive:

# quality: ignore[POT02] - process scheduler is intentionally non-terminating
while True:
    run_one_bounded_cycle()

Require a specific rationale after the marker. Never add a suppression merely to make the checker pass.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.