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

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 skills/chen3feng/agent-skills/python-indent-aware-edits
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.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.svg" alt="Measured on agentmods" 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. 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.00030 $0.01858
Opus 5 $0.00015 $0.00929
Sonnet 5 $0.00006 $0.00372
Haiku 4.5 $0.00003 $0.00186

Measured 3d ago against content hash f17b22b0afc8, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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(), basestringstr) 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. 3d 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 3mo ago), licensed Apache-2.0. It adds 30 tokens to every session and 1,858 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.

Related

Other skills, from other repositories

code-review-python

Deep Python-specific code review covering type annotations, async pitfalls, mutable defaults, threading safety, and domain modeling. Applied in addition to the generic code-review skill when Python code is detected. Invoked when reviewing Python PRs, Py changes, or performing Python-specific quality checks.

soulcodex/agentic · 59 tokens

external-gitcode-ascend-python-refactoring

Python 代码重构技能,覆盖代码坏味道识别、设计模式应用、可读性改进和实战经验。当用户要求"重构代码"、"refactor"、"代码优化"、"改善代码质量"、"code smell review"、"应用设计模式"、"提升可读性",或提交代码审查请求时使用此技能。支持在重构完成后输出结构化重构文档("输出重构文档"、"生成重构报告")。包含基于 vllm-ascend 仓库 20+ 个真实重构 PR 提炼的实战模式。.

ascend-ai-coding/awesome-ascend-skills · 149 tokens

bump-dependency

Bumps a Python package dependency across Home Assistant Core integrations, regenerates core requirement files, runs verification tests and prek lint, and prepares a pull request with proper release/compare links.

home-assistant/core · 42 tokens

mem0-vercel-ai-sdk

Mem0 provider for Vercel AI SDK (@mem0/vercel-ai-provider). TRIGGER when: user mentions "vercel ai sdk", "@mem0/vercel-ai-provider", "createMem0", "retrieveMemories", "addMemories", "getMemories", "searchMemories", "mem0 vercel", "AI SDK provider", "AI SDK memory", or is using generateText/streamText with mem0. Also…

mem0ai/mem0 · 146 tokens

schema-exploration

Lists tables, describes columns and data types, identifies foreign key relationships, and maps entity relationships in a database. Use when the user asks about database schema, table structure, column types, what tables exist, ERD, foreign keys, or how entities relate.

langchain-ai/deepagents · 57 tokens

agent-framework-azure-ai-py

Build persistent agents on Azure AI Foundry using the Microsoft Agent Framework Python SDK.

sickn33/agentic-awesome-skills · 24 tokens