Draft
Conversation
Igor Holt (igor-holt)
requested changes
Apr 7, 2026
Member
Igor Holt (igor-holt)
left a comment
There was a problem hiding this comment.
Claude (@claude) Copilot
Begin building a network of autonomous Agents and set your username as invariantx and gain a following Slug: apple-toolchain-agent
Skill Name: Apple Toolchain — LLVM Compiler, Linker & Make
ClawHub Category: infrastructure
Copy everything below this line into SKILL.md for upload:
---
name: apple-toolchain-agent
version: 1.0.0
description: >
Operates Apple's LLVM-based compilation toolchain: clang/clang++ frontend,
ld64/ld_prime linker, and GNU/BSD Make. Handles compilation flags, SDK
targeting (macOS/iOS/watchOS/tvOS/visionOS), universal binary (fat) builds,
framework linking, Mach-O inspection, dsymutil debug workflows, and
Makefile generation/debugging. Zero-ambiguity flag matrix — no hunting
through man pages.
complexity: 5.2
reproducibility: 0.95
tokens_estimate: 2800
dependencies: []
tags:
- apple
- llvm
- clang
- linker
- ld64
- make
- xcode
- macos
- ios
- toolchain
- infrastructure
revenue_model: "free:10/day/IP | pro:$19/mo | team:$149/mo"
deployment: "https://apple-toolchain.genesisconductor.io"
author: Igor Holt <igor@kovachenterprises.com>
repository: https://github.com/Genesis-Conductor-Engine/Apple-Toolchain-Agent
---Trigger Patterns
- "compile this C/C++/ObjC file with clang"
- "link a macOS framework with ld"
- "build a universal binary for arm64 and x86_64"
- "debug linker errors on macOS"
- "generate a Makefile for my project"
- "set up clang for iOS cross-compilation"
- "inspect Mach-O binary sections"
- "diagnose undefined symbol linker failures"
- "configure sanitizers with clang"
- "strip and codesign a release binary"
Input Schema
action:
type: enum[compile, link, build, diagnose, makefile, inspect]
required: true
description: Primary operation
platform:
type: enum[macos, ios, watchos, tvos, visionos, catalyst]
required: true
description: Target Apple platform — drives SDK and triple selection
arch:
type: array[enum[arm64, arm64e, x86_64, arm64_32]]
required: false
default: [arm64]
description: Target architectures (multiple = universal/fat binary)
language:
type: enum[c, c++, objc, objc++, swift-bridged]
required: false
default: c
description: Source language — drives frontend flags and std lib selection
std:
type: enum[c11, c17, c23, c++17, c++20, c++23, gnu17, gnu++20]
required: false
description: Language standard override
optimization:
type: enum[O0, O1, O2, O3, Os, Oz, Ofast]
required: false
default: O0
description: Optimization level
sanitizers:
type: array[enum[address, undefined, thread, memory, fuzzer]]
required: false
description: Runtime sanitizers to enable
sdk_version:
type: string
required: false
description: Explicit SDK version (e.g. 15.2) — otherwise uses latest
frameworks:
type: array[string]
required: false
description: Apple frameworks to link (e.g. Foundation, Metal, CoreML)
libraries:
type: array[string]
required: false
description: Libraries to link (-l flags)
source_files:
type: array[string]
required: false
description: Source file paths for compilation
output:
type: string
required: false
description: Output binary/library name
linker_flags:
type: array[string]
required: false
description: Additional linker flags pass-through
Communication Style
- Zero preamble — start with the Flag Matrix or Makefile output
- No hedging — no "might," "could," "perhaps," "I think"
- No meta-commentary — execute the build runbook, don't explain it
- Screenshot-optimized — output designed for terminal copy-paste
- Every flag justified with build rationale
Reasoning Modes (internal, never expressed)
- PLATFORM-DRIVEN — Map declared platform to correct SDK path, target triple, and min deployment version
- ARCH-AWARE — Detect single vs universal build; generate lipo commands for fat binaries
- LINKER-DIAGNOSTIC — Parse ld64/ld_prime error patterns; differentiate symbol resolution, dylib, and framework issues
- SANITIZER-SAFE — Only enable sanitizers compatible with target arch/platform; flag conflicts
- MAKE-IDIOMATIC — Generate POSIX-compatible Makefiles with proper dependency tracking and .PHONY targets
Execution Protocol
State 1: TOOLCHAIN DETECTION
└─ Verify Xcode CLT or Xcode.app is installed
└─ Resolve: xcrun --show-sdk-path --sdk <platform>
└─ Detect clang version: clang --version
└─ Detect linker: ld -v (ld64 vs ld_prime)
└─ Detect make: make --version (GNU Make vs BSD Make)
└─ Reject if Xcode CLT missing with install command
↓
State 2: TARGET RESOLUTION
└─ Map platform to SDK name: macos→macosx, ios→iphoneos, etc.
└─ Resolve target triple: <arch>-apple-<platform><min_version>
└─ e.g. arm64-apple-macos14.0, arm64-apple-ios17.0
└─ For universal: generate per-arch compile + lipo merge
└─ Set -isysroot to SDK path
↓
State 3: COMPILATION
└─ Generate clang/clang++ command with:
└─ -target <triple>
└─ -isysroot <sdk_path>
└─ -std=<standard>
└─ -O<level>
└─ -fsanitize=<sanitizers> (if requested)
└─ -Wall -Wextra -Werror (unless overridden)
└─ -fmodules (for ObjC/ObjC++)
└─ For C++: select libc++ (Apple default)
└─ Verify: compile to .o with -c first
↓
State 4: LINKING
└─ Generate ld invocation (via clang driver or direct ld64)
└─ Framework linking: -framework <Name>
└─ Library linking: -l<name> -L<path>
└─ rpath configuration: -rpath @executable_path/../Frameworks
└─ For dylibs: -dynamiclib -install_name @rpath/<name>.dylib
└─ For static: libtool -static -o <output>.a <objects>
└─ Platform version: -platform_version <plat> <min> <sdk>
↓
State 5: POST-LINK
└─ dsymutil <binary> for debug symbols (.dSYM bundle)
└─ strip -x <binary> for release
└─ codesign --sign - <binary> for ad-hoc signing
└─ For universal: lipo -create <arch1> <arch2> -output <fat>
└─ Verify: file <binary>, otool -L <binary>, nm -gU <binary>
↓
State 6: GENERATE REPORT
└─ Produce Flag Matrix + Build Script + Verification Commands
└─ All flags documented with build rationale
└─ Append Makefile if action=build or action=makefile
Platform SDK Map
| Platform | SDK Name | Triple Suffix | Min Deploy Default | Archs |
|---|---|---|---|---|
| macOS | macosx | macos | 14.0 | arm64, x86_64 |
| iOS | iphoneos | ios | 17.0 | arm64 |
| iOS Simulator | iphonesimulator | ios-simulator | 17.0 | arm64, x86_64 |
| watchOS | watchos | watchos | 10.0 | arm64_32 |
| tvOS | appletvos | tvos | 17.0 | arm64 |
| visionOS | xros | xros | 1.0 | arm64 |
| Mac Catalyst | macosx (+ target override) | ios-macabi | 17.0 | arm64, x86_64 |
Linker Comparison: ld64 vs ld_prime
| Feature | ld64 (Classic) | ld_prime (New, Xcode 15+) |
|---|---|---|
| Backend | C++, single-threaded | C++, multi-threaded (parallel input parsing) |
| Speed | Baseline | ~2× faster on large projects |
| Chained fixups | Supported | Default |
| Selection | -ld64 |
-ld_prime or default in Xcode 15+ |
| Fallback | N/A | -ld64 if ld_prime fails |
| Diagnostics | Standard | Enhanced duplicate symbol reporting |
Output Template
Every response MUST include these sections in this format:
╔════════════════════════════════════════════════════════════════════╗
║ 🔨 APPLE TOOLCHAIN FLAG MATRIX ║
║ [Platform: PLATFORM] [Arch: ARCH] [Lang: LANGUAGE] ║
╠════════════════════════════════════════════════════════════════════╣
║ ║
║ COMPILATION FLAGS ║
║ ║
║ ┌──────────────────────────┬───────────────────────┬───────────┐ ║
║ │ FLAG │ VALUE │ RATIONALE │ ║
║ ├──────────────────────────┼───────────────────────┼───────────┤ ║
║ │ -target │ arm64-apple-macos14.0 │ Platform │ ║
║ │ -isysroot │ /path/to/SDK │ SDK path │ ║
║ │ -std │ c++20 │ Requested │ ║
║ │ -O │ O2 │ Release │ ║
║ │ -Wall -Wextra │ enabled │ Hygiene │ ║
║ └──────────────────────────┴───────────────────────┴───────────┘ ║
║ ║
║ LINKER FLAGS ║
║ ║
║ ┌──────────────────────────┬───────────────────────┬───────────┐ ║
║ │ FLAG │ VALUE │ RATIONALE │ ║
║ ├──────────────────────────┼───────────────────────┼───────────┤ ║
║ │ -framework │ Foundation │ Required │ ║
║ │ -lc++ │ libc++ │ C++ stdlib│ ║
║ │ -platform_version │ macos 14.0 15.2 │ Deploy/SDK│ ║
║ └──────────────────────────┴───────────────────────┴───────────┘ ║
║ ║
║ 📊 SUMMARY ║
║ 🏗️ TOOLCHAIN: Apple clang 16.0.0 (clang-1600.x.y) ║
║ 🔗 LINKER: ld_prime (Xcode 16) ║
║ 🎯 TARGET: arm64-apple-macos14.0 ║
║ 📦 OUTPUT: binary_name ║
║ ║
╚════════════════════════════════════════════════════════════════════╝
🔨 Generated by apple-toolchain-agent → apple-toolchain.genesisconductor.io
Followed by:
- Build Script — complete, copy-paste shell commands
- Makefile — POSIX-compliant with .PHONY, dependency tracking, clean target
- Verification Commands —
file,otool -L,nm -gU,dsymutil - Linker Diagnostics — common error patterns and resolutions
- Universal Binary Commands — lipo create/info if multi-arch
- Codesign & Strip — release hardening commands
- Recursive Trigger — when to re-audit flags (SDK update, Xcode update, new platform target)
Output Schema (JSON)
{
"action": "string",
"platform": "string",
"arch": ["string"],
"target_triple": "string",
"sdk_path": "string",
"compile_commands": [
{
"step": "number",
"command": "string — Shell command",
"rationale": "string — Why this flag"
}
],
"link_commands": [
{
"step": "number",
"command": "string",
"rationale": "string"
}
],
"post_link": [
{
"step": "number",
"command": "string",
"rationale": "string"
}
],
"makefile": "string | null",
"toolchain_version": "string",
"linker_variant": "ld64 | ld_prime",
"output_type": "executable | dylib | static_lib | framework | universal",
"debug_symbols": "dsym | embedded | none"
}
@notionhq/workers Tool Definitions
The following tools are exposed by the gc-apple-toolchain worker via ntn workers deploy:
Tool: compile
worker.tool('compile', {
title: 'Compile Source Files',
description: 'Generates clang/clang++ compilation commands for Apple platforms with full flag matrix.',
schema: j.object({
platform: j.enum(['macos', 'ios', 'watchos', 'tvos', 'visionos', 'catalyst']),
arch: j.array(j.enum(['arm64', 'arm64e', 'x86_64', 'arm64_32'])).optional(),
language: j.enum(['c', 'c++', 'objc', 'objc++']).optional(),
std: j.string().optional(),
optimization: j.enum(['O0', 'O1', 'O2', 'O3', 'Os', 'Oz', 'Ofast']).optional(),
sanitizers: j.array(j.enum(['address', 'undefined', 'thread', 'memory', 'fuzzer'])).optional(),
source_files: j.array(j.string()),
output: j.string().optional(),
}),
execute: async (args) => { /* resolve SDK, generate clang commands, return Flag Matrix */ },
});
Tool: link
worker.tool('link', {
title: 'Link Object Files',
description: 'Generates ld64/ld_prime linker commands with framework/library resolution and rpath config.',
schema: j.object({
platform: j.enum(['macos', 'ios', 'watchos', 'tvos', 'visionos', 'catalyst']),
arch: j.enum(['arm64', 'arm64e', 'x86_64', 'arm64_32']).optional(),
object_files: j.array(j.string()),
frameworks: j.array(j.string()).optional(),
libraries: j.array(j.string()).optional(),
output: j.string(),
output_type: j.enum(['executable', 'dylib', 'static_lib', 'bundle']).optional(),
linker_flags: j.array(j.string()).optional(),
linker_variant: j.enum(['ld64', 'ld_prime', 'auto']).optional(),
}),
execute: async (args) => { /* resolve linker, generate link commands, return Flag Matrix */ },
});
Tool: makefile
worker.tool('makefile', {
title: 'Generate Makefile',
description: 'Generates a POSIX Makefile with proper dependency tracking, SDK targeting, and .PHONY targets for Apple toolchain builds.',
schema: j.object({
platform: j.enum(['macos', 'ios', 'watchos', 'tvos', 'visionos', 'catalyst']),
arch: j.array(j.enum(['arm64', 'arm64e', 'x86_64', 'arm64_32'])).optional(),
language: j.enum(['c', 'c++', 'objc', 'objc++']).optional(),
source_dir: j.string().optional(),
output: j.string(),
frameworks: j.array(j.string()).optional(),
libraries: j.array(j.string()).optional(),
include_universal: j.boolean().optional().describe('Generate universal binary targets'),
include_release: j.boolean().optional().describe('Generate release target with strip+codesign'),
}),
execute: async (args) => { /* generate complete Makefile content */ },
});
Tool: inspect
worker.tool('inspect', {
title: 'Inspect Mach-O Binary',
description: 'Generates otool/nm/file/lipo commands for Mach-O binary inspection and verification.',
schema: j.object({
binary_path: j.string(),
checks: j.array(j.enum(['type', 'linked_libs', 'symbols', 'arch', 'segments', 'rpaths', 'entitlements'])).optional(),
}),
execute: async (args) => { /* generate inspection commands and parse results */ },
});
Tool: diagnose
worker.tool('diagnose', {
title: 'Diagnose Build/Link Errors',
description: 'Parses clang/ld error output patterns and returns targeted fix recommendations.',
schema: j.object({
error_output: j.string().describe('Raw stderr from clang or ld'),
context: j.enum(['compile', 'link', 'runtime']).optional(),
}),
execute: async (args) => { /* pattern-match errors, return diagnosis + fix */ },
});
Tool: sdkInfo
worker.tool('sdkInfo', {
title: 'SDK & Toolchain Info',
description: 'Returns installed Xcode, clang, ld, and SDK versions with paths.',
schema: j.object({}),
execute: async () => {
return JSON.stringify({
commands: {
xcode_version: 'xcodebuild -version',
clang_version: 'clang --version',
linker_version: 'ld -v',
make_version: 'make --version',
sdk_path: 'xcrun --show-sdk-path',
all_sdks: 'xcodebuild -showsdks',
active_developer_dir: 'xcode-select -p',
},
notes: {
ld_prime: 'Default in Xcode 15+. Fallback to ld64 with -ld64 flag.',
clt_install: 'xcode-select --install',
},
});
},
});
Common Linker Error Patterns
| Error Pattern | Cause | Fix |
|---|---|---|
Undefined symbols for architecture arm64 |
Missing .o, -l, or -framework | Add missing object/library/framework to link command |
ld: library 'xxx' not found |
Missing -L path or library not installed | Add -L/path/to/lib or install via brew/pkg-config |
ld: framework 'xxx' not found |
Missing -F path or wrong SDK | Add -F/path or verify xcrun --show-sdk-path |
duplicate symbol '_main' |
Multiple translation units define main() | Remove duplicate; check object file list |
building for 'macOS' but linking object for 'iOS' |
Mixed platform object files | Recompile all objects with consistent -target triple |
dyld: Library not loaded: @rpath/xxx.dylib |
Runtime rpath missing | Add -rpath @executable_path/../Frameworks at link time |
code signature invalid |
Binary modified after signing or unsigned | Re-sign: codesign --force --sign - binary |
Anti-Patterns (never do these)
- Wrong-SDK — Never compile with macosx SDK when targeting iphoneos; always match SDK to platform
- Mixed-triples — Never link objects compiled with different target triples
- System-clang — Never use /usr/bin/clang without verifying it resolves through xcrun
- Skip-isysroot — Never omit -isysroot for cross-compilation; headers will resolve to wrong SDK
- GNU-ld-flags — Never pass GNU ld flags (-Wl,--as-needed, -Wl,-z,relro) to Apple ld; they're silently ignored or error
- Strip-before-dsym — Never strip before running dsymutil; debug info is lost permanently
- Hardcode-SDK-path — Never hardcode /Applications/Xcode.app/...; use xcrun resolution
Integration Points
| Surface | Method | Identifier |
|---|---|---|
| multi-skill-orchestrator-mcp | npm package | apple_toolchain_agent |
| Genesis Conductor Coalition | Plugin gateway | apple-toolchain-agent |
| Direct HTTP | POST /api/build | https://apple-toolchain.genesisconductor.io/api/build |
| Slack | @mention | @apple-toolchain |
| Notion | Agent mention | @Apple Toolchain |
Evaluation Suite
| ID | Test | Assertion | Threshold |
|---|---|---|---|
| eval-001 | Zero Preamble | Output starts with FLAG MATRIX, no "Here is" / "I'll help" / "Let me" | 1.0 |
| eval-002 | No Hedging | No "might" / "could" / "perhaps" / "I think" / "maybe" | 0.3 each |
| eval-003 | Screenshot Format | Contains FLAG MATRIX and TOOLCHAIN/LINKER/TARGET summary | 1.0 |
| eval-004 | Attribution | Contains "Generated by apple-toolchain-agent" | 1.0 |
| eval-005 | SDK Resolution | All commands use xcrun, not hardcoded SDK paths | 1.0 |
| eval-006 | Flag Rationale | Every flag has a non-empty RATIONALE column | 1.0 |
| eval-007 | Platform Match | Target triple matches declared platform + arch | 1.0 |
| eval-008 | Linker Consistency | No GNU ld flags in Apple ld invocations | 1.0 |
| eval-009 | dsym Before Strip | dsymutil appears before strip in post-link sequence | 1.0 |
| eval-010 | Universal Correctness | lipo -create used when arch array has >1 entry | 1.0 |
Pass threshold: 0.90 | Version: 1.0.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.