🎯 What problem it solves
Before Composer Skills, Go programs that needed to interact with the PHP/Composer ecosystem had only one path: exec.Command + string parsing. That path is painful to write, fragile to run, and exhausting to maintain. This page spells out those pain points and how Composer Skills resolves each one.
😩 The pain of the old way
The code below is a pattern that exists in countless Go projects:
// The old way — fragile, untyped, no error handling
out, _ := exec.Command("composer", "audit").Output()
lines := strings.Split(string(out), "\n")
// Then you have to parse these strings yourself...
// - Table column widths can change
// - Locales (Chinese/English) can change
// - Composer version upgrades change the output format
// - Mis-parse one field and the whole pipeline fails silentlyIts problems go far beyond "ugly code":
- 🛠️ Untyped: Everything is a
string; the compiler can't help, errors only surface at runtime. - 🔒 No error handling:
exec.Commandfailures get swallowed, vulnerability reports become empty strings, and CI falsely reports "safe". - 📦 Fragile format: A Composer upgrade or a locale switch breaks every regex.
- 🌐 Cross-platform traps: No
whichon Windows, differentgrepbehavior on macOS,runtime.GOOSbranches everywhere. - 🤔 Environment dependencies: Target machine has no Composer? The program just crashes, and the user has to dig through docs to install it themselves.
😊 The elegance of the new way
The same task, written with Composer Skills, looks like this:
// The new way — typed, tested, auto-installing
result, _ := comp.AuditWithJSON()
fmt.Printf("Vulnerabilities: %d\n", result.Found)
for _, v := range result.Advisories {
fmt.Printf("⚠ %s: %s (%s)\n", v.Package, v.Title, v.Severity)
}The compiler checks types for you, structured fields are available on demand, and output format changes no longer matter — because the SDK has already adapted internally.
🛠️🔒📦 Pain point vs. solution
Manually parsing exec.Command output
234 typed Go methods returning structured results (AuditInfo, OutdatedInfo, VersionInfo, etc.) with compile-time type checking — no more string parsing.
No structured vulnerability audit results
AuditWithJSON returns a struct with Found, Advisories, and Severity, directly usable for CI failure decisions and report generation.
Hand-writing HTTP requests to Packagist
20 typed API methods return Go structs directly — search, statistics, and security advisories in a single call, pure Go with no PHP needed.
Re-tabulated in Markdown for quick scanning:
| Pain point | Composer Skills solution |
|---|---|
🛠️ Manually parsing exec.Command output | 234 typed Go methods returning structured results |
| 🌐 Hand-writing HTTP requests to Packagist | 20 typed API methods returning Go structs directly |
| 🔍 "Is Composer installed on this machine?" | Cross-OS detector that finds it everywhere |
| 📦 "No Composer — what now?" | Auto-installer that downloads Composer + PHP for you |
| 💻 Different code per OS | Smart defaults that pick brew, apt, or direct download per platform |
| 🔒 Vulnerability reports only via regex | AuditWithJSON returns a struct; read Found/Advisories directly |
| ✅ Is composer.json valid? | ValidateStructured returns a structured result with error line numbers |
💡 Why not just call system commands directly?
You might think: "I'll just wrap exec.Command myself." In practice, that layer grows and grows:
- Handle Windows
wherevs. Unixwhich - Parse the output of 20 categories and over a hundred subcommands
- Degrade gracefully or auto-install when Composer is missing
- Mock every command for testing
- Handle timeouts, working directory, environment variables, stdin
Composer Skills turns that layer into a product: 234 methods + 450+ tests + cross-platform + auto-install, ready out of the box. You focus on business logic; the SDK does the dirty work.
The real cost of wrapping it yourself
A "simple-looking" composer audit wrapper — accounting for cross-platform path detection, output parsing, error propagation, timeout control, and mock testing — often runs 200+ lines and needs ongoing maintenance. Composer Skills has already written and tested it for you.
🧭 Next steps
- 🚀 Ready to get hands-on? Head to Getting started.
- 🏗️ Want to understand the boundary between the two SDKs? See Dual SDK architecture.
- 📦 Want to know about dependencies and system requirements? See Installation.