All skills
johnrogers avatar

/generating-swift-package-docs

@798c536

Use when encountering unfamiliar import statements, exploring dependency APIs, or when user asks "what's import X" or "what does X do". Generates on-demand API documentation for Swift package dependencies.

Use this Skill: https://skilld.dev/gh/johnrogers/claude-swift-engineering/generating-swift-package-docs

This session only. Nothing lands on disk.

reference.md

≈960 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Swift Package Documentation Generator - Reference

Automatically generates comprehensive API documentation for Swift package dependencies using interfazzle.

Contents

Features

  • Automatic package resolution: Maps module names to package names using dependency information
  • Smart caching: Checks for existing documentation before generating
  • Clean integration: Uses OS temporary directories for generation with automatic cleanup
  • Comprehensive output: Combines all generated markdown with package README files
  • Version-aware: Generates docs with version-specific filenames (major.minor format)

Command-Line Usage

python3 ./scripts/generate_docs.py <module_or_package_name> <xcodeproj_path>

Arguments

  • module_or_package_name: The Swift module or package name (e.g., ButtonKit, Defaults)
  • xcodeproj_path: Path to the Xcode project file (e.g., /path/to/MyApp.xcodeproj)

Example

python3 ./scripts/generate_docs.py ButtonKit /Users/yourname/Code/MyProject/MyProject.xcodeproj

Output:

/Users/yourname/Code/MyProject/dependency-docs/ButtonKit-0.6.md

How It Works

From within Claude Code, this skill automatically:

  1. Resolves module to package using shared Swift package utilities
  2. Checks for existing documentation in dependency-docs/
  3. If docs don't exist:
    • Locates the package in DerivedData
    • Extracts version from git tags (major.minor only)
    • Runs interfazzle generate with OS temporary directory
    • Concatenates all generated .md files
    • Appends the package's README if it exists
    • Saves to dependency-docs/<package-name>-<major.minor>.md
    • Temporary directory is automatically cleaned up
  4. Returns the documentation file path

When to Use

Use this skill when:

  • You encounter an unfamiliar module import and need its API documentation
  • You want to explore a dependency's API surface
  • You need to reference package documentation while coding
  • Working with Swift packages and need quick access to their public interfaces

Example Scenario

When you encounter an unfamiliar import:

import ButtonKit

The skill generates (or retrieves) documentation at:

<project>/dependency-docs/ButtonKit-0.6.md

Requirements

  • Python 3.6+
  • interfazzle CLI tool installed and in PATH (https://github.com/czottmann/interfazzle)
  • Shared Swift package utilities (_shared/swift_packages.py)
  • Project must be built at least once (DerivedData must exist)

Output Format

Documentation files are saved as:

<project>/dependency-docs/<PackageName>-<major.minor>.md

This means:

  • Documentation is generated once per major.minor version
  • Subsequent requests for the same package version use the cached file
  • Patch version updates don't trigger regeneration
  • Major or minor version updates will generate new documentation

Implementation

The skill consists of:

  • SKILL.md - Skill definition with YAML frontmatter
  • reference.md - This detailed reference documentation
  • scripts/generate_docs.py - Main implementation script (relative to skill directory)
  • ../_shared/swift_packages.py - Shared Swift package utilities (used by multiple skills)

Testing

Verified working with:

  • ButtonKit 0.6.1 → ButtonKit-0.6.md (21KB)
  • Defaults 8.2.0 → Defaults-8.2.md (47KB)
  • Diagnostics 5.1.0 → Diagnostics-5.1.md (comprehensive API docs)

All successfully generated, cached on subsequent runs, with automatic temp directory cleanup.

Source: SKILL.md on GitHub

No alerts16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill generates documentation for Swift packages by reading project metadata and executing external CLI tools. It presents a low risk of indirect prompt injection as it processes untrusted README files and code from external dependencies without sanitization.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer7mo

    4 files scanned · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 798c536. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Dormantupdated 9 months ago

README badge

README badge for johnrogers/claude-swift-engineering/generating-swift-package-docs