clj-surgeon

Analyze and transform Clojure code via AST operations with EDN results.

34|7|Updated Apr 24, 2026
One-click install
npx skills add https://github.com/realgenekim/clj-surgeon --skill clj-surgeon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: clj-surgeon
Source: https://github.com/realgenekim/clj-surgeon/tree/main
Command: npx skills add https://github.com/realgenekim/clj-surgeon --skill clj-surgeon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

clj-surgeon provides fast, AST-driven tooling to explore and refactor Clojure codebases, replacing brittle text edits with safe structural transformations.

Core Features & Use Cases

  • Outline top-level forms in a namespace with exact line boundaries and forward-reference detection.
  • Perform deterministic refactors such as moving forms, extracting to new namespaces, fixing forward declares, and renaming namespaces.
  • Manage CLJC work flows (merge, split, add-require, analyze) and per-project dependency views for multi-file codebases.

Quick Start

Outline a file with :ls to see form boundaries, then perform refactors with :mv or :extract!.

Frequently Asked Questions about clj-surgeon

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor Clojure code structurally instead of using text edits?

Structural Clojure refactoring operates directly on the AST for safe transformations. clj-surgeon accelerates this by performing deterministic edits like moving forms and extracting namespaces without brittle text replacements.

How do I extract top-level forms into a new namespace in Clojure?

You can extract top-level forms into a new namespace using AST-driven refactoring. clj-surgeon supports extraction workflows with dry-run safety checks and EDN-based results to ensure predictable namespace creation.

What is the best way to manage CLJC merge and split workflows across a project?

CLJC merge, split, add-require, and analyze workflows are supported for multi-file codebases. clj-surgeon provides per-project dependency views and cross-project workflows to manage CLJC files deterministically.

Does clj-surgeon require babashka to run Clojure AST transformations?

Yes, clj-surgeon relies on babashka and rewrite-clj dependencies to ensure predictable, token-efficient refactoring. These dependencies enable the AST operations and EDN-based result outputs.

How do I detect forward references when outlining a Clojure namespace?

Outlining top-level forms with exact line boundaries includes forward-reference detection. clj-surgeon's outline feature identifies these references to help you plan structural fixes like declare fixes.

Can I preview structural refactoring changes before applying them to a Clojure file tree?

Yes, dry-run safety checks allow you to preview structural refactoring changes. clj-surgeon uses frontmatter-driven entry points and EDN-based results to guarantee deterministic edits across single files or entire trees.