sumac
CLAUDE.md2 starsChanged 8 months agoMITView on GitHub
Use sxmc (Sumac) as a first-class terminal workflow in this repo for Claude Code. Summary: Sumac — bring out what your tools can do (Skills × MCP × CLI) Preferred flow: 1. sxmc --help 2. sxmc serve --help High-confidence subcommands: - serve: Start the MCP server (serves skills over MCP) - skills: Manage skills - stdio: Connect to an MCP server via stdio (MCP Server → CLI) - http: Connect to an MCP server via HTTP (MCP Server → CLI)…
- Installs packages
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/sxmc-cli-ai.mdCursor rule
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
43 rules. About 0 are common, 9 are distinctive, and 34 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
34
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 4
Use sxmc (Sumac) as a first-class terminal workflow in this repo for Claude Code.
- Very specific: line 20
When the exact CLI surface is unclear, start with sxmc inspect cli <tool> --depth 1 --format json-pretty instead of pasting raw help output …
- Very specific: line 21
When the MCP surface is unknown, start with sxmc stdio "<cmd>" --list or sxmc mcp grep <pattern> before guessing tool calls.
- Very specific: line 22
When the API surface is unknown, start with sxmc api <url-or-spec> --list before constructing requests by hand.
- Distinctive: line 23
Keep bulky output in files or pipes when possible.
- Very specific: line 24
Prefer machine-friendly flags like --json when the CLI supports them.
- Very specific: line 108
No pinned rust-toolchain file, .nvmrc, Dockerfile, or compose file detected at repo root
- Very specific: line 122
Use snake_case for Rust modules and standalone files such as src/cli_args.rs, src/command_handlers.rs, and src/security/skill_scanner.rs.
- Very specific: line 123
Use mod.rs as the barrel for grouped modules such as src/server/mod.rs, src/client/mod.rs, and src/output/mod.rs.
- Very specific: line 124
Keep helper scripts descriptive and lowercase with underscores in scripts/, for example scripts/smoke_portable_core.sh and …
- Very specific: line 125
Use kebab-case for skill fixture directories and package metadata where the external format expects it, for example …
- Very specific: line 126
Use snake_case for functions and methods throughout Rust code, for example resolve_secret in src/auth/secrets.rs, inspect_codebase in …
- Very specific: line 128
Prefer imperative helper names for setup and orchestration code, such as spawn_http_server, wait_for_http_server, and …
- Very specific: line 129
Use snake_case for locals and parameters, for example working_dir, skill_name, return_type, and recommended_commands across …
- Very specific: line 130
Use short temporary names only inside tight scopes.
- Very specific: line 131
Use PascalCase for structs and enums such as SxmcError in src/error.rs, SkillFrontmatter in src/skills/models.rs, and …
- Very specific: line 132
Use SCREAMING_SNAKE_CASE for cross-function constants, for example PROFILE_BUNDLE_SCHEMA in src/main.rs and TOOL_GET_AVAILABLE_SKILLS in …
- Very specific: line 133
When external file formats use kebab-case keys, encode that with serde attributes rather than Rust field naming changes, as in …
- Very specific: line 140
Treat Clippy warnings as errors.
- Very specific: line 141
Keep non-Rust packaging files valid through lightweight tool-native checks instead of a separate lint stack: node --check …
- Distinctive: line 143
No alias system is used.
- Very specific: line 149
Use ok_or_else for missing required values and argument validation, as in src/server/handler.rs and src/client/graphql.rs.
- Very specific: line 150
Use unwrap() freely in tests and small setup helpers, but keep production paths on explicit Result returns.
- Very specific: line 151
Prefer structured error messages that include the failing path, command, or operation name.
- Very specific: line 153
Write user-facing data and machine-readable payloads to stdout with println!, especially in src/main.rs and src/command_handlers.rs.
- Very specific: line 154
Write warnings, progress notes, and transport diagnostics to stderr with eprintln!, often prefixed with [sxmc], as in src/server/mod.rs, …
- Very specific: line 158
Use doc comments on public modules and externally useful functions, as in src/lib.rs, src/auth/secrets.rs, and src/output/mod.rs.
- Very specific: line 159
Add short inline comments only when explaining compatibility behavior, parsing edge cases, or interop constraints, for example the …
- Very specific: line 164
Prefer focused helpers in library modules, such as resolve_header in src/auth/secrets.rs, build_call_tool_params in src/client/mod.rs, and …
- Very specific: line 166
Prefer borrowed inputs like &Path, &str, &[String], and &[PathBuf], as seen throughout src/client/, src/auth/, and src/skills/.
- Very specific: line 168
Use dedicated option structs when a helper needs several related knobs, as in ApiCommandOptions and SkillListOptions in …
- Very specific: line 173
Use mod.rs to assemble grouped subsystems such as src/client/mod.rs and src/server/mod.rs.
- Very specific: line 174
Keep binary-only helpers in src/main.rs, src/cli_args.rs, and src/command_handlers.rs rather than exporting them from the library.
- Very specific: line 175
Use Rust mod.rs files as the only barrel pattern.
- Distinctive: line 176
Do not introduce extra re-export-only files outside the normal module system unless the API surface genuinely needs it.
- Distinctive: line 178
Add new Rust code under an existing subsystem and match that module’s import grouping, error style, and naming.
- Very specific: line 179
Use crate::error::Result<T> and map errors with context instead of propagating raw library errors into user-facing code.
- Distinctive: line 180
Keep structured stdout clean.
- Distinctive: line 181
Add doc comments only where they help readers understand a public API or a non-obvious edge case.
- Very specific: line 260
Use crate::error::Result<T> and SxmcError from src/error.rs across non-protocol modules.
- Distinctive: line 269
Before using Edit, Write, or other file-changing tools, start work through a GSD command so planning artifacts and execution context stay …
- Distinctive: line 271
Use these entry points:
- Distinctive: line 276
Do not make direct repo edits outside a GSD workflow unless the user explicitly asks to bypass it.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- sxmc:begin cli-ai:claude-code -->Sumac CLI Surface: sxmc
Use sxmc (Sumac) as a first-class terminal workflow in this repo for Claude Code.
Summary: Sumac — bring out what your tools can do (Skills × MCP × CLI)
Preferred flow:
sxmc --helpsxmc serve--help
High-confidence subcommands:
serve: Start the MCP server (serves skills over MCP)skills: Manage skillsstdio: Connect to an MCP server via stdio (MCP Server → CLI)http: Connect to an MCP server via HTTP (MCP Server → CLI)mcp: Use baked MCP connections in a token-efficient, mcp-cli-style workflow
Guidance:
- When the exact CLI surface is unclear, start with
sxmc inspect cli <tool> --depth 1 --format json-prettyinstead of pasting raw help output into chat. - When the MCP surface is unknown, start with
sxmc stdio "<cmd>" --listorsxmc mcp grep <pattern>before guessing tool calls. - When the API surface is unknown, start with
sxmc api <url-or-spec> --listbefore constructing requests by hand. - Keep bulky output in files or pipes when possible.
- Prefer machine-friendly flags like
--jsonwhen the CLI supports them. - Re-check
--helpbefore using low-confidence flows. - Startup file convention last verified against official docs on 2026-03-21.
- Reference: https://docs.anthropic.com/en/docs/claude-code/memory
<!-- sxmc:end cli-ai:claude-code --><!-- GSD:project-start source:PROJECT.md -->Project
Sumac
Sumac (sxmc) is a Rust CLI that makes AI assistants stop guessing how local
tools, APIs, MCP servers, skills, and project surfaces work. It inspects real
interfaces, turns them into structured profiles and artifacts, and uses those
to generate host-facing docs, client config, MCP wrappers, and discovery
outputs from one installable binary.
This planning cycle is for a brownfield product-preserving rewrite. The product surface stays broad and stable, but the internals are being rebuilt so Sumac feels like a cleaner native system rather than an accumulated set of layers and special cases.
Core Value: Sumac must let AI systems understand and use real existing tools and interfaces without bespoke glue, while staying fast, local-first, and reliable.
Constraints
- Compatibility: Public CLI behavior, JSON outputs, generated files, and
release semantics must remain stable throughout the migration — Sumac is
already a stable
1.xproduct - Migration shape: The rewrite should happen inside the existing repo as a cleaner internal core, not as a second product or a long-lived parallel code tree — slice-by-slice cutover is the strategy
- Release cadence: Releases continue during the rewrite — migration cannot freeze shipping
- Product scope: Sumac keeps the same broad product surface during this cycle — the rewrite is internal architecture work, not a product narrowing
- Testing: Each migrated slice must prove parity with the existing product path before old logic is retired
<!-- GSD:project-end --><!-- GSD:stack-start source:codebase/STACK.md -->Technology Stack
Languages
- Rust 2021 edition - application code and CLI entrypoints in
Cargo.toml,src/main.rs, andsrc/lib.rs - JavaScript (Node.js ESM) - npm install wrapper and launcher metadata in
packaging/npm/package.jsonandpackaging/npm/scripts/install.mjs - Shell + PowerShell - release, smoke, and CI automation in
.github/workflows/ci.yml,.github/workflows/release.yml, andscripts/ - Python - helper scripts such as
scripts/fixture_inventory.pyandscripts/benchmark_startup.py
Runtime
- Native Rust CLI binary
sxmcbuilt fromsrc/main.rs - Async runtime: Tokio 1 with
fullfeatures inCargo.toml - HTTP serving/client runtime: Axum 0.8 + Reqwest 0.13 in
src/server/mod.rs,src/server/wrap.rs,src/client/api.rs,src/client/openapi.rs, andsrc/client/graphql.rs - Cargo via the stable Rust toolchain used in
.github/workflows/ci.ymland.github/workflows/release.yml - Lockfile: present in
Cargo.lock - Secondary package manager: npm for distribution wrapper only in
packaging/npm/package.json
Frameworks
rmcp1.2 - MCP client/server transport layer for stdio and streamable HTTP insrc/server/mod.rs,src/server/wrap.rs,src/client/mcp_stdio.rs, andsrc/client/mcp_http.rsclap4 - CLI argument parsing insrc/cli_args.rsserde/serde_json/serde_yaml/toml- structured config, spec, and artifact parsing insrc/client/,src/bake/config.rs, andsrc/cli_surfaces/- Rust built-in test harness via
cargo testwith integration coverage intests/cli_integration.rs assert_cmd2 andpredicates3 - CLI assertions inCargo.tomlandtests/cli_integration.rs- Shell smoke suites in
scripts/test-sxmc.sh,scripts/smoke_portable_core.sh, andscripts/smoke_test_clients.sh - GitHub Actions - CI and release packaging in
.github/workflows/ci.ymland.github/workflows/release.yml clap_complete4 - shell completion generation wired throughsrc/cli_args.rsnotify8 - file watch/reload support insrc/server/mod.rs
Key Dependencies
rmcp1.2 - the MCP protocol backbone for Sumac’s core product surface inCargo.tomlreqwest0.13 withrustls- all outbound HTTP for MCP, OpenAPI, GraphQL, bundle publish/pull, registry push/pull, npm install downloads, and webhooks insrc/client/,src/main.rs, andpackaging/npm/scripts/install.mjsaxum0.8 - inbound HTTP endpoints for hosted MCP and bundle registry servers insrc/server/mod.rs,src/server/wrap.rs, andsrc/main.rsclap4 - the large multi-command CLI surface insrc/cli_args.rstokio1 - async execution, child processes, and HTTP serving insrc/main.rs,src/server/, andsrc/client/rusqlite0.32 withbundled- SQLite schema inspection for discovery insrc/client/database.rspostgres0.19 - PostgreSQL schema inspection for discovery insrc/client/database.rshmac0.12 +sha20.10 +ed25519-dalek2 - bundle signing and verification insrc/main.rsdirs6 +tempfile3 - local config/cache placement and atomic writes insrc/paths.rs,src/bake/config.rs, andsrc/cache.rs
Configuration
- Local/global state roots are derived from
SXMC_CONFIG_HOME,SXMC_CACHE_HOME,XDG_CONFIG_HOME, andXDG_CACHE_HOMEinsrc/paths.rs - HTTP auth and signing secrets are supplied at runtime, typically via
env:orfile:indirection handled insrc/auth/secrets.rs - NPM wrapper install behavior is controlled by
SXMC_NPM_SKIP_DOWNLOADandSXMC_NPM_DOWNLOAD_BASEinpackaging/npm/scripts/install.mjs - Rust manifest and dependency graph:
Cargo.tomlandCargo.lock - NPM wrapper metadata:
packaging/npm/package.json - Homebrew packaging:
packaging/homebrew/sxmc.rb - CI/release automation:
.github/workflows/ci.ymland.github/workflows/release.yml - No pinned
rust-toolchainfile,.nvmrc, Dockerfile, or compose file detected at repo root
Platform Requirements
- Rust stable toolchain with Cargo is required for the canonical install/build path in
README.mdand.github/workflows/ci.yml - Node.js
>=18is required only for the npm wrapper inpackaging/npm/package.json - Unix and Windows shell coverage are both part of CI in
.github/workflows/ci.yml - Primary deployment target is a standalone CLI distributed via crates.io, GitHub Releases, npm wrapper metadata, and Homebrew as documented in
README.md,.github/workflows/release.yml,packaging/npm/scripts/install.mjs, andpackaging/homebrew/sxmc.rb - Prebuilt release assets are published for Linux x64, macOS x64, macOS arm64, and Windows x64 in
.github/workflows/release.ymland consumed bypackaging/npm/scripts/install.mjs - Hosted runtime mode is optional and uses Axum HTTP servers for MCP and registry endpoints in
src/server/mod.rs,src/server/wrap.rs, andsrc/main.rs
<!-- GSD:stack-end --><!-- GSD:conventions-start source:CONVENTIONS.md -->Conventions
Naming Patterns
- Use
snake_casefor Rust modules and standalone files such assrc/cli_args.rs,src/command_handlers.rs, andsrc/security/skill_scanner.rs. - Use
mod.rsas the barrel for grouped modules such assrc/server/mod.rs,src/client/mod.rs, andsrc/output/mod.rs. - Keep helper scripts descriptive and lowercase with underscores in
scripts/, for examplescripts/smoke_portable_core.shandscripts/benchmark_startup.py. - Use kebab-case for skill fixture directories and package metadata where the external format expects it, for example
tests/fixtures/simple-skill/andpackaging/npm/package.json. - Use
snake_casefor functions and methods throughout Rust code, for exampleresolve_secretinsrc/auth/secrets.rs,inspect_codebaseinsrc/client/codebase.rs, andformat_tool_resultinsrc/output/mod.rs. - Name tests as
test_<behavior>ortest_<condition>_<expected_result>, as intest_split_frontmatterinsrc/skills/parser.rsandtest_api_list_json_suppresses_detection_banner_on_stderrintests/cli_integration.rs. - Prefer imperative helper names for setup and orchestration code, such as
spawn_http_server,wait_for_http_server, andwrite_discovery_snapshotintests/cli_integration.rs. - Use
snake_casefor locals and parameters, for exampleworking_dir,skill_name,return_type, andrecommended_commandsacrosssrc/executor.rs,src/server/handler.rs, andsrc/client/codebase.rs. - Use short temporary names only inside tight scopes; otherwise favor descriptive names like
discovery_tool_manifestsinsrc/cli_args.rsandstderr_captureinsrc/server/wrap.rs. - Use
PascalCasefor structs and enums such asSxmcErrorinsrc/error.rs,SkillFrontmatterinsrc/skills/models.rs, andStructuredOutputFormatinsrc/output/mod.rs. - Use
SCREAMING_SNAKE_CASEfor cross-function constants, for examplePROFILE_BUNDLE_SCHEMAinsrc/main.rsandTOOL_GET_AVAILABLE_SKILLSinsrc/server/handler.rs. - When external file formats use kebab-case keys, encode that with serde attributes rather than Rust field naming changes, as in
#[serde(rename_all = "kebab-case")]insrc/skills/models.rs.
Code Style
- Format Rust with
cargo fmt. CI enforcescargo fmt --all --checkin.github/workflows/ci.yml, and release certification repeats that inscripts/certify_release.sh. - No
rustfmt.toml,.editorconfig, or repository-level formatter config is present. Use default Rustfmt behavior. - Shell scripts that act as CI or smoke entrypoints generally use
set -euo pipefail, as inscripts/certify_release.sh,scripts/smoke_portable_core.sh, andscripts/smoke_portable_fixtures.sh. - Python helper scripts are small, typed, and
main()-driven, as inscripts/benchmark_startup.py. - Node packaging scripts stay minimal and runtime-focused; there is no repo-level ESLint or Prettier config. Validation is syntax-only through
node --checkin.github/workflows/ci.ymlandscripts/certify_release.sh. - Treat Clippy warnings as errors. CI runs
cargo clippy --all-targets --all-features -- -D warningsin.github/workflows/ci.yml. - Keep non-Rust packaging files valid through lightweight tool-native checks instead of a separate lint stack:
node --check packaging/npm/bin/sxmc.js,node packaging/npm/scripts/install.mjs, andruby -c packaging/homebrew/sxmc.rbinscripts/certify_release.sh.
Import Organization
- No alias system is used.
- Inside library code, import sibling modules with
crate::..., as insrc/server/handler.rs. - Inside
src/main.rs, import public crate APIs throughsxmc::...and local private modules through baremodplususe, as insrc/main.rs.
Error Handling
- Return the shared
crate::error::Result<T>alias from library functions, as insrc/auth/secrets.rs,src/executor.rs,src/client/api.rs, andsrc/skills/parser.rs. - Convert lower-level failures into
SxmcErrorwith contextual strings viamap_err, as insrc/client/codebase.rs,src/client/openapi.rs, andsrc/client/graphql.rs. - Use
ok_or_elsefor missing required values and argument validation, as insrc/server/handler.rsandsrc/client/graphql.rs. - Use
unwrap()freely in tests and small setup helpers, but keep production paths on explicitResultreturns. - Prefer structured error messages that include the failing path, command, or operation name. This pattern shows up across
src/auth/secrets.rs,src/executor.rs, andsrc/client/*.
Logging
- Write user-facing data and machine-readable payloads to stdout with
println!, especially insrc/main.rsandsrc/command_handlers.rs. - Write warnings, progress notes, and transport diagnostics to stderr with
eprintln!, often prefixed with[sxmc], as insrc/server/mod.rs,src/server/wrap.rs, andsrc/cli_surfaces/inspect.rs. - Preserve stdout as the machine-readable channel when a command supports structured output.
tests/cli_integration.rsexplicitly checks this behavior intest_api_list_json_suppresses_detection_banner_on_stderr. - No
tracing,log, orenv_loggerintegration is present in the repo.
Comments
- Use doc comments on public modules and externally useful functions, as in
src/lib.rs,src/auth/secrets.rs, andsrc/output/mod.rs. - Add short inline comments only when explaining compatibility behavior, parsing edge cases, or interop constraints, for example the zero-argument MCP note in
src/client/mod.rsand the JSON parsing fallback note insrc/main.rs. - In long pattern or shell files, use banner comments to divide sections, as in
src/security/patterns.rsandscripts/test-sxmc.sh. - Not used.
- JavaScript files in
packaging/npm/bin/sxmc.jsandpackaging/npm/scripts/install.mjsrely on clear names and small function scope instead of docblock comments.
Function Design
- Prefer focused helpers in library modules, such as
resolve_headerinsrc/auth/secrets.rs,build_call_tool_paramsinsrc/client/mod.rs, andparse_argument_hintinsrc/skills/parser.rs. - Accept that orchestration-heavy files grow large when they centralize CLI routing.
src/main.rs,src/cli_args.rs, andsrc/cli_surfaces/inspect.rsare current exceptions and should be extended with new helpers before adding more inline branching. - Prefer borrowed inputs like
&Path,&str,&[String], and&[PathBuf], as seen throughoutsrc/client/,src/auth/, andsrc/skills/. - Model command surfaces with enums and typed structs rather than raw strings when possible, for example
Commandsand subcommand enums insrc/cli_args.rs. - Use dedicated option structs when a helper needs several related knobs, as in
ApiCommandOptionsandSkillListOptionsinsrc/command_handlers.rs. - Return
serde_json::Valuefor machine-readable command payloads and summaries, as insrc/client/codebase.rs,src/client/graphql.rs, and many helpers insrc/main.rs. - Return typed structs or enums where the code needs richer internal modeling, such as
Skill,ExecResult,DiscoveryResource, andOpenApiOperation.
Module Design
- Declare the public surface centrally in
src/lib.rswith onepub modper subsystem and a short doc comment for each module. - Use
mod.rsto assemble grouped subsystems such assrc/client/mod.rsandsrc/server/mod.rs. - Keep binary-only helpers in
src/main.rs,src/cli_args.rs, andsrc/command_handlers.rsrather than exporting them from the library. - Use Rust
mod.rsfiles as the only barrel pattern. - Do not introduce extra re-export-only files outside the normal module system unless the API surface genuinely needs it.
Practical Rules To Follow
- Add new Rust code under an existing subsystem and match that module’s import grouping, error style, and naming.
- Use
crate::error::Result<T>and map errors with context instead of propagating raw library errors into user-facing code. - Keep structured stdout clean; put diagnostics on stderr.
- Add doc comments only where they help readers understand a public API or a non-obvious edge case.
- For scripts under
scripts/, prefer portable bash or small Python utilities over heavyweight tooling, and preserve the currentset -euo pipefail/main()style.
<!-- GSD:conventions-end --><!-- GSD:architecture-start source:ARCHITECTURE.md -->Architecture
Pattern Overview
src/main.rsis the operational entrypoint and contains the top-levelclapdispatch for the fullsxmccommand surface.- Reusable behavior is pushed into library modules under
src/, so the binary mostly orchestrates parsing, path resolution, output selection, and module calls. - The product is organized around surface translation: skills to MCP in
src/skills/+src/server/, MCP or APIs to CLI insrc/client/, and CLI to AI host artifacts insrc/cli_surfaces/.
Layers
- Purpose: Parse arguments, choose the subcommand path, and glue together modules for runtime execution.
- Location:
src/main.rs,src/cli_args.rs,src/command_handlers.rs - Contains:
clapenum definitions, shared option structs, top-levelmatch cli.command, and reusable handlers for skills and API commands. - Depends on: Nearly every exported module from
src/lib.rs, especiallysrc/client/,src/server/,src/skills/,src/cli_surfaces/,src/paths.rs, andsrc/output/mod.rs. - Used by: The
sxmcbinary declared inCargo.toml. - Purpose: Discover skill folders, parse
SKILL.md, enumeratescripts/andreferences/, and build in-memory skill models. - Location:
src/skills/discovery.rs,src/skills/parser.rs,src/skills/models.rs,src/skills/install.rs,src/skills/generator.rs - Contains: Filesystem scans, YAML frontmatter parsing, argument-hint parsing, install metadata, and OpenAPI-to-skill generation.
- Depends on:
src/error.rs,src/paths.rs, and the local filesystem. - Used by:
src/server/mod.rs,src/server/handler.rs,src/command_handlers.rs, and subcommands insrc/main.rs. - Purpose: Turn parsed skills or wrapped CLI profiles into MCP servers over stdio or streamable HTTP.
- Location:
src/server/mod.rs,src/server/handler.rs,src/server/wrap.rs - Contains:
SkillsServer, HTTP auth and limit handling, watch/reload support, discovery snapshot mounting, and wrapped-CLI tool derivation. - Depends on:
src/skills/,src/discovery_snapshots.rs,src/executor.rs,src/cli_surfaces/, andrmcp/axum. - Used by:
Commands::ServeandCommands::Wrapinsrc/main.rs. - Purpose: Normalize external sources into a common CLI interaction model.
- Location:
src/client/api.rs,src/client/openapi.rs,src/client/graphql.rs,src/client/mcp_stdio.rs,src/client/mcp_http.rs,src/client/database.rs,src/client/codebase.rs,src/client/traffic.rs,src/client/commands.rs - Contains: API autodetection, MCP transport clients, schema discovery, codebase inspection, HAR inspection, and shared command definitions.
- Depends on:
src/error.rs,src/output/mod.rs,src/projection.rs, HTTP/MCP crates, and local files for schema/codebase discovery. - Used by:
src/main.rsandsrc/command_handlers.rs. - Purpose: Inspect a real CLI into a normalized profile, then generate AI-facing docs, configs, wrappers, and supporting artifacts.
- Location:
src/cli_surfaces/inspect.rs,src/cli_surfaces/model.rs,src/cli_surfaces/render.rs,src/cli_surfaces/materialize.rs - Contains: command-spec parsing, profile caching, profile models, host registry, artifact rendering, and file materialization policies.
- Depends on:
src/cache.rs,src/paths.rs,src/error.rs, and the filesystem. - Used by:
inspect,init,scaffold,doctor,setup,add,status,sync, andwrapflows insrc/main.rs. - Purpose: Provide durable local/global state, formatting, execution, and lightweight utilities.
- Location:
src/paths.rs,src/cache.rs,src/bake/config.rs,src/auth/secrets.rs,src/output/mod.rs,src/executor.rs,src/projection.rs,src/error.rs - Contains: local vs global install paths, cache TTL storage, baked connection persistence, secret/header resolution, output formatting, subprocess execution, JSON field projection, and the crate-wide error type.
- Depends on: filesystem, environment variables, and serde-based serialization.
- Used by: most modules in the crate.
- Purpose: Scan skills and MCP surfaces for risky content and report findings with severity.
- Location:
src/security/mod.rs,src/security/skill_scanner.rs,src/security/mcp_scanner.rs,src/security/patterns.rs - Contains: finding models, pattern heuristics, and report formatting.
- Depends on:
src/error.rsand parsed skill or MCP metadata. - Used by:
scan-related flows insrc/main.rs.
Data Flow
- User-global state lives under
src/paths.rspaths such as~/.config/sxmcand~/.cache/sxmc. - Repo-local generated AI state lives under
.sxmc/whenInstallScope::Localis used viasrc/paths.rs. - Baked connection definitions are stored through
BakeStoreinsrc/bake/config.rs. - CLI inspection cache entries are file-based and TTL-driven in
src/cache.rs.
Key Abstractions
- Purpose: In-memory representation of one skill directory.
- Examples:
src/skills/models.rs, constructed insrc/skills/parser.rs - Pattern: Parse once from filesystem, then reuse for listing, serving, running, and security scanning.
- Purpose: MCP handler for skills, discovery resources, and hybrid helper tools.
- Examples:
src/server/handler.rs - Pattern: Precompute indexes for skills, tools, and resources, then answer MCP list/read/call requests from those indexes.
- Purpose: Canonical JSON-friendly description of a CLI command surface.
- Examples:
src/cli_surfaces/model.rs, produced bysrc/cli_surfaces/inspect.rs - Pattern: Treat the normalized profile as source of truth, then derive docs, configs, wrappers, and drift workflows from it.
- Purpose: Persist reconnectable definitions for MCP and API sources.
- Examples:
src/bake/config.rs - Pattern: Load once from config storage, mutate in memory, and persist atomically through a temp file.
- Purpose: Shared operation model for API-backed CLI execution.
- Examples:
src/client/commands.rs, consumed bysrc/client/api.rs - Pattern: Different backends expose one list-and-execute shape to the CLI surface.
Entry Points
- Location:
src/main.rs - Triggers: Running
sxmc ... - Responsibilities: Parse CLI arguments, branch on subcommands, resolve state roots, call library modules, and emit output.
- Location:
src/lib.rs - Triggers: Embedding
sxmcas a Rust crate - Responsibilities: Re-export stable internal modules such as
server,skills,client,cli_surfaces,security, andbake. - Location:
tests/cli_integration.rs - Triggers:
cargo test - Responsibilities: Exercise the compiled binary, spawn temporary HTTP/MCP fixtures, and validate end-to-end command flows.
Error Handling
- Use
crate::error::Result<T>andSxmcErrorfromsrc/error.rsacross non-protocol modules. - Convert HTTP/MCP boundary failures into protocol-native errors inside
src/server/handler.rsandsrc/server/mod.rs. - Emit non-fatal warnings to stderr for partial failures during listing or optional behavior, especially in
src/command_handlers.rsandsrc/main.rs.
Cross-Cutting Concerns
<!-- GSD:architecture-end --><!-- GSD:workflow-start source:GSD defaults -->GSD Workflow Enforcement
Before using Edit, Write, or other file-changing tools, start work through a GSD command so planning artifacts and execution context stay in sync.
Use these entry points:
/gsd:quickfor small fixes, doc updates, and ad-hoc tasks/gsd:debugfor investigation and bug fixing/gsd:execute-phasefor planned phase work
Do not make direct repo edits outside a GSD workflow unless the user explicitly asks to bypass it.
<!-- GSD:workflow-end --><!-- GSD:profile-start -->Developer Profile
Profile not yet configured. Run
/gsd:profile-userto generate your developer profile. This section is managed bygenerate-claude-profile-- do not edit manually.
<!-- GSD:profile-end -->Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

