analyzing-code-structure

analyzing-code-structure is a skill for Claude Code, Codex from SebastienDegodez/copilot-instructions. It costs 42 tokens per session (806 once invoked), scanned A, original, Apache-2.0.

A guide for searching and changing source code by its structure rather than exact text. Structural matching can recognize functions, method calls, and classes even when formatting or names differ.

In plain words
What is it for?
Use it for structural searches and refactors, especially when an ordinary text edit reports that the selected old text is not unique.
Why use it?
It avoids ambiguous text replacements, such as when the same code appears more than once or whitespace makes exact matching unreliable.

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/sebastiendegodez/copilot-instructions/analyzing-code-structure
Any agent
npx skills add SebastienDegodez/copilot-instructions --skill analyzing-code-structure
Clone the repo
git clone --depth 1 https://github.com/SebastienDegodez/copilot-instructions

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 analyzing-code-structure

README.md
[![agentmods](https://agentmods.dev/badge/skills/sebastiendegodez/copilot-instructions/analyzing-code-structure.svg)](https://agentmods.dev/skills/sebastiendegodez/copilot-instructions/analyzing-code-structure)
Your own site
<a href="https://agentmods.dev/skills/sebastiendegodez/copilot-instructions/analyzing-code-structure"><img src="https://agentmods.dev/badge/skills/sebastiendegodez/copilot-instructions/analyzing-code-structure.svg" alt="Measured on agentmods" height="20"></a>
Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 806 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.00042 $0.00806
Opus 5 $0.00021 $0.00403
Sonnet 5 $0.00008 $0.00161
Haiku 4.5 $0.00004 $0.00081

Measured 4d ago against content hash d7b37c00c927, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

analyzing-code-structure 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 4d 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.

plugins/minimal-context-tools/skills/analyzing-code-structure/SKILL.md · 75 lines

How it starts

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

ast-grep: Structural Code Search and Editing

Always invoke the ast-grep skill for structural code search and refactoring - do not execute bash commands directly.

Default Strategy

Invoke analyzing-code-structure skill for structural code search and refactoring. Use when:

  • Text-based Edit tool fails with "old_string not unique"
  • Need formatting-independent pattern matching
  • Performing structural changes across code

Common workflow: Invoke extracting-code-structure skill first, then analyzing-code-structure skill for structural modifications.

Use ast-grep to solve the "old_string not unique" problem by matching code structure instead of exact text. This enables refactoring across formatting variations and structural patterns.

When to Use analyzing-code-structure vs Text Tools

Use analyzing-code-structure when:

  • Structural code changes - Refactoring function signatures, method calls, class structures
  • Formatting-independent matching - Need to find code regardless of whitespace/line breaks
  • Pattern variations - Matching similar structures with different variable names/arguments
  • "old_string not unique" problem - Edit tool fails because text appears in multiple contexts
  • Complex queries - Finding nested structures, specific AST patterns

Use text tools (Edit/Grep) when:

  • Simple, unique string replacement - The exact text appears once or in consistent format
  • Non-code files - Markdown, configs, data files
  • Comment/documentation edits - Content that isn't code structure
  • Very small changes - Single line, obvious context, no ambiguity

Key Decision Rule

If editing code structure and there's any ambiguity in text matching → use analyzing-code-structure.

ast-grep's primary value: Solves the "old_string not unique" problem by matching structure instead of exact text.

Detailed Reference

For comprehensive patterns, syntax, metavariables, common use cases, language-specific tips, and best practices, load analyzing-code-structure guide when needing:

  • Complex pattern matching with metavariables
  • Language-specific syntax variations
  • Advanced refactoring workflows
  • Integration with other tools
  • Common pitfalls and solutions

Read the full file on GitHub · 75 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 75 lines · 42 tokens per session scan A d7b37c00c927

Subscribe to this mod's changes

analyzing-code-structure is a skill published in the GitHub repository SebastienDegodez/copilot-instructions (192 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 42 tokens to every session and 806 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-30.