c-to-ast

c-to-ast is a skill for Claude Code, Codex from Narwhal-Lab/MagicSkills. It costs 50 tokens per session (1,010 once invoked), scanned A, original, MIT.

A code-analysis tool that turns C source code into an abstract syntax tree: a structured outline of the program's functions, statements, and expressions.

In plain words
What is it for?
It helps parse C files, inspect how code is organised, and prepare for static or security analysis such as finding possible vulnerabilities.
Why use it?
It makes C program structure easier to inspect than reading raw source alone. The structured output can be passed to later analysis tools.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps parse C files, inspect how code is organised, and prepare for static or security analysis such as finding possible vulnerabilities.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/narwhal-lab/magicskills/c_2_ast
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 Narwhal-Lab/MagicSkills --skill c_2_ast
Clone the repo
git clone --depth 1 https://github.com/Narwhal-Lab/MagicSkills

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 c-to-ast

README.md
[![agentmods](https://agentmods.dev/badge/skills/narwhal-lab/magicskills/c_2_ast/github.svg)](https://agentmods.dev/skills/narwhal-lab/magicskills/c_2_ast)
Your own site
<a href="https://agentmods.dev/skills/narwhal-lab/magicskills/c_2_ast"><img src="https://agentmods.dev/badge/skills/narwhal-lab/magicskills/c_2_ast/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 c-to-ast

Your own site · 80×15
<a href="https://agentmods.dev/skills/narwhal-lab/magicskills/c_2_ast"><img src="https://agentmods.dev/badge/skills/narwhal-lab/magicskills/c_2_ast.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 50 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,010 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.00050 $0.01010
Opus 5.5 $0.00020 $0.00404
Sonnet 5.5 $0.00010 $0.00202
Haiku 4.5 $0.00005 $0.00101

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

Security

Grade A, and why

c-to-ast 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.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/c_2_ast.py, scripts/save_c.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

skill_template/c_2_ast/SKILL.md · 171 lines

How it starts

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

C to AST Skill

Purpose

This Skill converts C source code into its Abstract Syntax Tree (AST) representation.

Use this Skill when you need to:

  • Understand the structure of a C program
  • Analyze functions, statements, and expressions
  • Prepare C code for static analysis or security analysis
  • Transform C code into an intermediate representation (AST)
  • Feed structured code information into downstream tools or agents

The AST is generated using a Python-based C parser and printed directly to standard output.


When to Use

Apply this Skill when the user asks to:

  • “Parse this C code”
  • “Convert this C file to an AST”
  • “Show me the AST of this C program”
  • “Analyze the structure of this C code”
  • “Extract syntax tree / abstract syntax tree from C”

This Skill is especially useful in compiler frontends, program analysis, and security research workflows.


Instructions

Follow these steps strictly and in order:

  1. Navigate to the Skill scripts directory

    • Change working directory to the scripts/ directory under this skill:
      scripts/
      
  2. Handle the input C source

    • If the user provides a path to a .c file, use it directly.
    • If the user provides inline C code as a string, you must first save it to a C source file using the provided script:
      python3 save_c.py --input "<C code string>" --output <output_dir> --filename <filename>.c
      
    • Ensure the generated file has a .c extension and is successfully written to disk.
  3. Run the AST extraction script

    • Convert the C source file to its Abstract Syntax Tree by executing:
      python3 c_2_ast.py --input <path_to_c_file>
      
  4. Do not modify the source code

    • This Skill is strictly read-only.
    • Do not rewrite, reformat, optimize, or otherwise alter the C code.
  5. Return the AST output verbatim

    • The script prints the AST directly to standard output.
    • Return the output exactly as produced.
    • Do not summarize, paraphrase, or restructure the AST.
    • Preserve indentation, hierarchy, and node ordering.

Read the full file on GitHub · 171 lines

Files

What ships with it

7 files 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. 1mo ago First seen · 171 lines · 50 tokens per session scan A 1d6023883af8

Subscribe to this mod's changes

c-to-ast is a skill published in the GitHub repository Narwhal-Lab/MagicSkills (317 stars, last pushed 6mo ago), licensed MIT. It adds 50 tokens to every session and 1,010 once invoked, about $0.0002 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-30.

Related

Other skills, from other repositories

windbg-diagnostic-method

Use with every WinDbg plugin investigation to apply evidence-first reasoning, confidence calibration, contrarian review, structured reporting, and deterministic validation. Not a bug-family-specific triage skill.

microsoft/win-dev-skills · 42 tokens

windbg-kernel-bugcheck-triage

Use when a kernel dump reports a Windows bugcheck; decode parameters and recover exception or trap context before investigating your driver. Not for user-mode process crashes or blaming a module from its name alone.

microsoft/win-dev-skills · 50 tokens

windbg-user-exception-triage

Use when a native C/C++ app, service, or user-mode driver host (including UMDF) crashes with a structured exception in a dump or WinDbg session, including native faults inside managed processes. Not for managed .NET exceptions, WinUI/XAML app errors, or kernel bugchecks.

microsoft/win-dev-skills · 69 tokens

windbg-user-heap-corruption-investigation

Use when an app, service, or user-mode driver host heap fails or Application Verifier detects corruption; inspect history and bounds. Not for kernel pool corruption or ordinary OOM.

microsoft/win-dev-skills · 46 tokens

windbg-user-virtual-memory-exhaustion

Use when a native app, service, or user-mode driver host allocation fails; distinguish VA exhaustion, fragmentation, and commit pressure. Not for managed .NET heap growth, proving a leak from one snapshot, or corruption.

microsoft/win-dev-skills · 54 tokens

windbg-user-wait-chain-analysis

Use when an app, service, or user-mode driver host is unresponsive on locks, COM/RPC, I/O, or another process; follow the blocker chain. Not for a crash solely from an exception stack.

microsoft/win-dev-skills · 52 tokens