# unjs/magicast

🧀  Programmatically modify JavaScript and TypeScript source codes with a simplified, elegant and familiar syntax powered by recast and babel.

Repository: https://github.com/unjs/magicast
Canonical: https://ross.abutalabs.com/products/magicast
Language: TypeScript
License: MIT
License Family: permissive
Last push: 2026-08-26T10:38:21+00:00

## Health v2 (maintenance only)
Score: 94/100 (v2, computed 2026-09-02T17:46:02.011165+00:00)
- activity 99, release rhythm 83, longevity 100
- inputs: {"age_days": 1926, "days_push": 7, "days_rel": 33, "gap_med": 78, "n_releases_24m": 6}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 2477, forks 50 (observed 2026-08-28T04:06:55.114728+00:00)

## What it is
Magicast is a TypeScript library for programmatically modifying JavaScript and TypeScript source files using a simple, JSON-like proxy API over ASTs parsed by recast and Babel. It preserves original code formatting while allowing easy manipulation of imports, exports, and function call arguments.

## Use cases
- programmatically edit config files like defineConfig calls
- write codemods to update JS/TS source code
- modify module imports and exports in a file
- append values to exported arrays while preserving formatting
- generate or transform TypeScript configuration files
- manipulate function call arguments in source code

## When to choose
- you need to edit JS/TS files programmatically without losing formatting
- writing codemods or config file editors (e.g., Nuxt modules)
- you want readable code manipulation instead of raw AST work

## When to avoid
- you only need to parse or lint code without writing it back
- you need full AST-level control for complex transformations (use Babel or jscodeshift directly)
- your target language is not JavaScript or TypeScript

## Facets
- artifact type: library
- maturity: active
- function: parser, developer-tools
- domain: developer-tools, parsers, web-development
- platform: -
- tags: ast-manipulation, codemod, typescript, recast, babel, code-generation, nodejs, javascript

## Member repositories
- unjs/magicast (main) score 94

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:06:55.114728+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T02:28:20.397199+00:00, confidence not recorded.
  - readme: https://github.com/unjs/magicast (fetched 2026-08-28T04:06:55.114728+00:00, sha 236220fffcb9)
  - registry_npm: https://registry.npmjs.org/magicast (fetched 2026-08-29T10:10:22.177646+00:00, sha 4b9044c71ceb)
- Data as of 2026-08-30T08:39:29.467469+00:00.
