14.5 C
Canberra
Wednesday, April 1, 2026

SwiftButler | Cocoanetics


SwiftButler | Cocoanetics

Earlier than I found out use macros to allow SwiftMCP, I experimented rather a lot with SwiftSyntax and constructed a venture that I known as SAAE – Swift AST Abstractor & Editor. Such it lay forgotten on a public GitHub repo. So I figured, it might deserve a brand new coat of paint and a greater identify.

The CLI of the venture has 4 major features presently:

  • analyze – Makes you might be lower down interface description for any variety of information. This fashion you’ll be able to hand the general public interface for a framework to your LLM with out it having to learn a lot of superfluous textual content.
  • examine – Does a super-fast native syntax examine throughout the scope of 1 file. This fashion you’ll be able to catch “apparent” syntax error in generated code earlier than you waste time on a protracted construct.
  • reindent – Generated code often doesn’t care about how you want your code reindented. This operate basically what CMD+I does in Xcode.
  • distribute – Generated code tends to wish to put all new code right into a single file ensuing an tons of declarations in big information. This operate splits all declarations into separate information. If protocol extensions it places them parallel to the declaration file with +Protocol added to the identify.

That is all some form of housekeeping work, so at first I wished to go together with maid. However my AI satisfied me that it is a unhealthy identify for a lot of causes, together with the truth that the time period “maid” is supposedly sexist. So I let myself be satisfied that butler is means higher. So we went with that.

SAAE turns into SwiftButler

So for model 1, I polished up the CLI a bit, gave it a --version command, and renamed it to butler. I added a SKILL.md file to assist with it getting used as an OpenClaw ability and in addition added it to my homebrew faucet as a way to simply set up it.

brew set up cocoanetics/faucet/swiftbutler

Then to make use of it simply do one thing like:

butler analyze Sources/MyModule --visibility public

The whole documentation for the CLI could be discovered on GitHub. Or simply set up it from ClawHub.

Granted, you can additionally ask your coding agent to do this type of refactoring. However coding brokers would try this by producing all of the extracted code from scratch and in addition to generated the code to be deleted as nicely. With this software it’s basically free.

This was the principle realization why I felt that butler could be fairly helpful in any Swift developer’s software belt.

And whereas watching my coding brokers at work I maintain seeing that they nonetheless have occasional bother with syntax and even get tripped up by their very own file modifying instruments. Cursor (and by extension VS Code) has a bonus over Codex and Claude by accessing a Swift Linter which tells the LLM proper then and there that there’s some syntax drawback.

I’ve but to attempt it in apply, however I feel the butler examine operate ought to have the ability to act as a primary line of defence linter for Codex or Claude Code. This emits all of the sorts of syntax errors you’d get from the syntax checker of the Swift compiler. It received’t have the ability to let you know if you’re calling a non-existing operate from one other file, however there are a lot of syntax issues it CAN let you know about. To a level there are even repair its offered.

Conclusion

LLMs may be getting higher and higher at writing appropriate code from the beginning, however even when they write good code there stay some refactoring operations that you simply’d be higher off doing deterministically by using instruments that may enable you to confirm and modify the summary syntax tree of your supply code.

When constructing SwiftButler I had a number of extra concepts for what it may/ought to do:

  • be certain that all public features have DocC feedback
  • be certain that all file headers adhere to a sure commonplace
  • extra bold: have some form of lookup operate that permits discovering declarations or features by identify or semantically
  • most bold: emulate cross-file syntax checking by verifying that declarations or features exist within the native venture

What do you suppose? What needs to be add subsequent?


Classes: Updates

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

[td_block_social_counter facebook="tagdiv" twitter="tagdivofficial" youtube="tagdiv" style="style8 td-social-boxed td-social-font-icons" tdc_css="eyJhbGwiOnsibWFyZ2luLWJvdHRvbSI6IjM4IiwiZGlzcGxheSI6IiJ9LCJwb3J0cmFpdCI6eyJtYXJnaW4tYm90dG9tIjoiMzAiLCJkaXNwbGF5IjoiIn0sInBvcnRyYWl0X21heF93aWR0aCI6MTAxOCwicG9ydHJhaXRfbWluX3dpZHRoIjo3Njh9" custom_title="Stay Connected" block_template_id="td_block_template_8" f_header_font_family="712" f_header_font_transform="uppercase" f_header_font_weight="500" f_header_font_size="17" border_color="#dd3333"]
- Advertisement -spot_img

Latest Articles