Renders SwiftUI code from prose, screenshots, or ASCII diagrams to a PNG image using Emacs and ImageRenderer. Useful for previewing UI layouts without Xcode.
Ships in emacs-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Generate SwiftUI code from the most recent interaction context, render it to a PNG using ImageRenderer, and output it as a markdown image so it renders inline.
The "context" can take any form: a prose description ("show a profile card with a photo on the left and name above bio on the right"), an attached screenshot or mockup image, an ASCII layout diagram, or actual Swift code. Translate whichever the user provided into a single ContentView.
For example, this ASCII diagram:
+------------------+--------------------------------------+
| | Name |
| +--------------------------------------+
| Photo | |
| | Biography |
| | |
+------------------+--------------------------------------+
should become an HStack with the photo on the left and a VStack { Name; Biography } on the right, sized so the photo spans the full height. Match proportions and stacking direction faithfully; choose reasonable placeholder content (e.g. Image(systemName: "person.crop.square.fill"), sample text) when the input doesn't specify.
ContentView. Helper views may be defined alongside.agent-skill-swiftui.el which lives alongside this skill file at skills/swiftui-preview/agent-skill-swiftui.el in the emacs-skills plugin directory.base64 and decode it on the elisp side:
emacsclient --eval "(progn (load \"/path/to/skills/swiftui-preview/agent-skill-swiftui.el\" nil t) (agent-skill-swiftui-render :swift-source (base64-decode-string \"$(base64 <<'SWIFT' | tr -d '\n'
struct ContentView: View {
var body: some View {
Text("Hello, SwiftUI!")
.font(.largeTitle)
.padding(40)
}
}
SWIFT
)\")))"
The 'SWIFT' heredoc delimiter is single-quoted so the source passes through verbatim — no shell escaping needed inside."/var/folders/.../agent-swiftui-XXXX.png") on success, or nil on failure.
Do NOT include import SwiftUI — the wrapper imports it. Provide only the view structs:
struct ContentView: View {
var body: some View {
VStack(spacing: 20) {
Text("Hello, SwiftUI!")
.font(.largeTitle)
RoundedRectangle(cornerRadius: 12)
.fill(Color.orange)
.frame(width: 200, height: 100)
}
.padding(40)
}
}
If the source contains no struct or class definitions, it is wrapped automatically as the body of a generated ContentView. Otherwise it must define ContentView itself.
ContentView when the source contains struct/class definitions.import SwiftUI in the source — the wrapper adds it.base64 | tr -d '\n' pipe inside the single-quoted 'SWIFT' heredoc — do not write a temp .swift file as an intermediate step.agent-skill-swiftui.el relative to this skill file's directory.emacsclient --eval command via the Bash tool.emacsclient prints the return value as an elisp literal — strip the surrounding " quotes from the path before emitting the markdown image link.) on its own line.nil return, inform the user that the SwiftUI render failed and show the source so they can debug.What SKILL.md sets; muted values are Claude Code's defaults
20 skills in this plugin
/d2This skill should be used when the user invokes "/d2" to create a diagram from the current context using D2 and output the resulting image path./describeThis skill should be used when the user invokes "/describe" to look up Emacs documentation via emacsclient./diredThis skill should be used when the user invokes "/dired" to open files from the latest interaction in an Emacs dired buffer via emacsclient./emacsclientAlways use emacsclient instead of emacs. This applies to all Emacs operations: user requests, byte compilation, check-parens, running ERT tests, and any other elisp evaluation. Exception: a project's own test/build entry points (make test, eask, eldev, CI scripts) may run even though they spawn emacs --batch internally./file-linksWhen referencing files, format them as markdown links with line numbers using GitHub-style #L syntax./github-activityThis skill should be used when the user invokes "/github-activity" to analyze a GitHub project's recent activity (PRs and issues) and produce a succinct, chart-backed health report./emacs-skills:swiftui-previewfrom emacs-skills
npx claudepluginhub xenodium/emacs-skills --plugin emacs-skillsOther plugins' skills for the same job