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 $0.00025 $0.00505
Sonnet 5 $0.00010 $0.00202
Haiku 4.5 $0.00005 $0.00101

Measured 10d ago against content hash 1d6023883af8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, 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 10d 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. 10d 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 (315 stars, last pushed 5mo ago), licensed MIT. It adds 50 tokens to every session and 1,010 once invoked, about $0.0003 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.

Related

Other skills, from other repositories

winui-session-report

Analyze the current or a recent agent session (GitHub Copilot CLI or Claude Code) and generate a diagnostic report. Use only when the user explicitly asks for session feedback, agent debugging, or a review of what happened during a build session. Do not inspect session data automatically.

microsoft/win-dev-skills · 61 tokens

spm-build-analysis

Analyze Swift Package Manager dependencies, package plugins, module variants, and CI-oriented build overhead that slow Xcode builds. Use when a developer suspects packages, plugins, or dependency graph shape are hurting clean or incremental build performance, mentions SPM slowness, package resolution time, build…

AvdLee/Xcode-Build-Optimization-Agent-Skill · 87 tokens

xcode-compilation-analyzer

Analyze Swift and mixed-language compile hotspots using build timing summaries and Swift frontend diagnostics, then produce a recommend-first source-level optimization plan. Use when a developer reports slow compilation, type-checking warnings, expensive clean-build compile phases, long CompileSwiftSources tasks…

AvdLee/Xcode-Build-Optimization-Agent-Skill · 74 tokens

code-explorer

Use this skill when exploring, analyzing, or understanding project/code structure. Required for tasks like "analyze project", "explore codebase", "understand how X works".

clacky-ai/openclacky · 40 tokens

xcode-project-analyzer

Audit Xcode project configuration, build settings, scheme behavior, and script phases to find build-time improvements with explicit approval gates. Use when a developer wants project-level build analysis, slow incremental builds, guidance on target dependencies, build settings review, run script phase analysis…

AvdLee/Xcode-Build-Optimization-Agent-Skill · 72 tokens

webflow-code-component:troubleshoot-deploy

Debug deployment failures for Webflow Code Components. Analyzes error messages, identifies root causes, and provides specific fixes for common issues.

webflow/webflow-skills · 38 tokens