python-indent-aware-edits

python-indent-aware-edits is a skill for Claude Code, Codex from chen3feng/agent-skills. It costs 30 tokens per session (1,858 once invoked), scanned A, original, Apache-2.0.

A safety check for multi-line edits inside Python blocks such as with, try, loops, functions, and classes. It verifies that the edited code still runs in the intended block scope, not only that Python can parse it.

In plain words
What is it for?
Use it after literal search-and-replace edits that rewrite nested Python code, especially inside with or try statements, to catch scope changes that syntax checks miss.
Why use it?
Python accepts extra indentation as valid syntax, so compile checks may pass even when code has accidentally moved outside a resource-management or error-handling block.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it after literal search-and-replace edits that rewrite nested Python code, especially inside with or try statements, to catch scope changes that syntax checks miss.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/chen3feng/agent-skills/python-indent-aware-edits
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.

Any agent
npx skills add chen3feng/agent-skills --skill python-indent-aware-edits
Clone the repo
git clone --depth 1 https://github.com/chen3feng/agent-skills

Made for: Claude Code, Codex.

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 python-indent-aware-edits

README.md
[![agentmods](https://agentmods.dev/badge/skills/chen3feng/agent-skills/python-indent-aware-edits/github.svg)](https://agentmods.dev/skills/chen3feng/agent-skills/python-indent-aware-edits)
Your own site
<a href="https://agentmods.dev/skills/chen3feng/agent-skills/python-indent-aware-edits"><img src="https://agentmods.dev/badge/skills/chen3feng/agent-skills/python-indent-aware-edits/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for python-indent-aware-edits

Your own site · 80×15
<a href="https://agentmods.dev/skills/chen3feng/agent-skills/python-indent-aware-edits"><img src="https://agentmods.dev/badge/skills/chen3feng/agent-skills/python-indent-aware-edits.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 30 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,858 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00030 $0.01858
Opus 5.5 $0.00012 $0.00743
Sonnet 5.5 $0.00006 $0.00372
Haiku 4.5 $0.00003 $0.00186

Measured 1mo ago against content hash f17b22b0afc8, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-indent-aware-edits 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 1mo 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.

skills/python-indent-aware-edits/SKILL.md · 188 lines

How it starts

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

Python indent-aware edits: compileall won't catch a dropped with / try scope

When to use

You are making a multi-line edit inside a block-introducing statement (with, try, for, if, def, class) using an editor tool that does literal search-and-replace (e.g. replace_in_file, multi_replace, sed -i with a multi-line pattern). The edit rewrites or replaces a nested suite — not just a single token.

If the edit is purely mechanical in-line rename (e.g. iteritems(d) → d.items(), basestring → str) done by sed that never touches the leading whitespace of any line, this skill does not apply.

Problem

Python's grammar treats any indentation greater than the enclosing block as a valid new suite. That means an accidentally over-indented line is still syntactically legal — compileall, ast.parse, python -c 'import mymodule' all pass — but the semantic scope has silently changed.

Concretely: an old_string that captured only the body lines of a with block (not the with statement itself) can be replaced with a new_string whose first line is indented to the with level. The body lifts out of with, the file f closes, and the line below it (still indented deeper) becomes the body of the outer statement instead. The module still imports. The bug only fires when the specific function is called.

Real symptom caught during a blade-build py2-shim cleanup:

# before (correct)
def dump(self, output_file_name):
    with open(output_file_name, 'w') as f:
        print('# header', file=f)
        for name, value in sorted(iteritems(self.configs)):
            self._dump_section(name, value, f)

A replace_in_file meant to rewrite only the for line used old_string starting after the with, and the tool re-emitted the for with the method-body indent (8 spaces) instead of the with-body indent (12 spaces):

# after (broken but syntactically valid)
def dump(self, output_file_name):
    with open(output_file_name, 'w') as f:
        print('# header', file=f)
    for name, value in sorted(self.configs.items()):   # ← escaped the `with`
            self._dump_section(name, value, f)         # ← over-indented, still legal

Read the full file on GitHub · 188 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. 1mo ago First seen · 188 lines · 30 tokens per session scan A f17b22b0afc8

Subscribe to this mod's changes

python-indent-aware-edits is a skill published in the GitHub repository chen3feng/agent-skills (5 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 30 tokens to every session and 1,858 once invoked, about $0.0001 per session on Opus 5.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.

Related

Other skills, from other repositories

python-code-quality

Code quality checks, linting, formatting, and type checking commands for the Agent Framework Python codebase. Use this when running checks, fixing lint errors, or troubleshooting CI failures.

microsoft/agent-framework · 40 tokens

plugin-architecture-patterns

Design, implement, or diagnose Xberg plugin traits, typed registries, priority collisions, lifecycle, native extractors, and Alef-generated Python plugin bridges. Load for plugin-system work, not ordinary extractor parsing.

xberg-io/xberg · 43 tokens

test-corpus

The testdocuments submodule is a bucket-fetched fixture corpus that is not committed. This skill covers readtestfixture, missing fixtures, valid A/B controls, and submodule push order. Load before running Rust tests on a fresh clone, setting up an A/B control, adding a fixture-backed test, or diagnosing…

xberg-io/xberg · 68 tokens

idapython

IDA Pro Python scripting for reverse engineering. Use when writing IDAPython scripts, analyzing binaries, working with IDA's API for disassembly, decompilation (Hex-Rays), type systems, cross-references, functions, segments, or any IDA database manipulation. Covers ida modules (50+), idautils iterators, and common…

mrexodia/ida-pro-mcp · 77 tokens

stack-trace-python-probe

Internal helper for meta-stack-trace-investigator. Use when a Python traceback needs Python-specific root-cause checks, pytest reproducer guidance, and defensive patch targets.

opensquilla/opensquilla · 40 tokens

memory-optimization

Optimize Python code for reduced memory usage and improved memory efficiency. Use when asked to reduce memory footprint, fix memory leaks, optimize data structures for memory, handle large datasets efficiently, or diagnose memory issues. Covers object sizing, generator patterns, efficient data structures, and memory…

benchflow-ai/skillsbench · 60 tokens