Image Loading logo

Image Loading

Community
rshankras
image-loading

Generates an image loading pipeline with memory/disk caching, deduplication, and a CachedAsyncImage SwiftUI view. Use when user wants image caching, lazy image loading, or a replacement for AsyncImage.

Overview

Publisherrshankras
Repositoryclaude-code-apple-skills
Skill nameimage-loading
Stars
744
Forks
70
Bundled files
2
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by rshankras on GitHub. Read the source before you install it.

Installation

Install the Image Loading AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/rshankras/claude-code-apple-skills.git /tmp/claude-code-apple-skills
mkdir -p .claude/skills
cp -r /tmp/claude-code-apple-skills/skills/generators/image-loading .claude/skills/image-loading
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Image Loading in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Image Loading on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Image Loading is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Image Loading Generator

Generate a production image loading pipeline with NSCache memory cache, LRU disk cache, request deduplication, image processing, and a drop-in CachedAsyncImage SwiftUI view.

When This Skill Activates

Use this skill when the user:

  • Asks to "add image caching" or "cache images"
  • Wants to "replace AsyncImage" or fix "AsyncImage has no cache"
  • Mentions "image loading pipeline" or "lazy image loading"
  • Asks about "image download" or "image prefetching"
  • Wants "thumbnail generation" or "image resizing"

Pre-Generation Checks

1. Project Context Detection

  • Check Swift version (requires Swift 5.9+)
  • Check deployment target (iOS 16+ / macOS 13+)
  • Check for @Observable support (iOS 17+ / macOS 14+)
  • Identify source file locations

2. Conflict Detection

Search for existing image loading:

Glob: **/*ImageCache*.swift, **/*ImageLoader*.swift, **/*ImagePipeline*.swift
Grep: "AsyncImage" or "UIImage" or "NSImage" or "ImageCache"

If third-party library found (Kingfisher, SDWebImage, Nuke):

  • Ask if user wants to replace or keep it
  • If keeping, don't generate — advise on best practices instead

3. Platform Detection

Determine if generating for iOS (UIImage) or macOS (NSImage) or both (cross-platform typealias).

Configuration Questions

Ask user via AskUserQuestion:

  1. Cache sizes?

    • Small (50 MB memory / 100 MB disk)
    • Medium (100 MB memory / 250 MB disk) — recommended
    • Large (200 MB memory / 500 MB disk)
  2. Image processing?

    • Resize to fit (downscale large images to save memory)
    • Thumbnail generation (create small thumbnails for lists)
    • None (cache original images only)
  3. Additional features? (multi-select)

    • Prefetching for collections (preload images for visible rows + buffer)
    • Placeholder and error images
    • Progress indicator during download
  4. Platform?

    • iOS only
    • macOS only
    • Cross-platform (iOS + macOS)

Generation Process

Step 1: Read Templates

Read image-loading-patterns.md for architecture guidance. Read templates.md for production Swift code.

Step 2: Create Core Files

Generate these files:

  1. ImageCache.swift — Protocol for cache interface
  2. MemoryImageCache.swift — NSCache-based with configurable size
  3. DiskImageCache.swift — FileManager LRU with expiration
  4. ImageDownloader.swift — Actor-based with deduplication + cancellation
  5. ImagePipeline.swift — Orchestrator (cache → download → process → store)

Step 3: Create UI Files

  1. CachedAsyncImage.swift — Drop-in SwiftUI view replacement

Step 4: Create Optional Files

Based on configuration:

  • ImageProcessor.swift — If resize or thumbnail selected
  • ImagePrefetcher.swift — If prefetching selected

Step 5: Determine File Location

Check project structure:

  • If Sources/ exists → Sources/ImageLoading/
  • If App/ exists → App/ImageLoading/
  • Otherwise → ImageLoading/

Output Format

After generation, provide:

Files Created

ImageLoading/
├── ImageCache.swift          # Protocol for cache interface
├── MemoryImageCache.swift    # NSCache-based memory cache
├── DiskImageCache.swift      # LRU disk cache with expiration
├── ImageDownloader.swift     # Actor-based downloader
├── ImagePipeline.swift       # Orchestrator
├── ImageProcessor.swift      # Resize, thumbnails (optional)
├── CachedAsyncImage.swift    # SwiftUI view
└── ImagePrefetcher.swift     # Collection prefetching (optional)

Integration Steps

Drop-in replacement for AsyncImage:

swift
// Before (no caching)
AsyncImage(url: user.avatarURL) { image in
    image.resizable().aspectRatio(contentMode: .fill)
} placeholder: {
    ProgressView()
}

// After (with caching)
CachedAsyncImage(url: user.avatarURL) { image in
    image.resizable().aspectRatio(contentMode: .fill)
} placeholder: {
    ProgressView()
}

In a List:

swift
List(users) { user in
    HStack {
        CachedAsyncImage(url: user.avatarURL) { image in
            image.resizable().frame(width: 44, height: 44).clipShape(Circle())
        } placeholder: {
            Circle().fill(Color.secondary.opacity(0.2)).frame(width: 44, height: 44)
        }
        Text(user.name)
    }
}

With prefetching:

swift
struct UsersListView: View {
    let users: [User]
    @State private var prefetcher = ImagePrefetcher()

    var body: some View {
        List(users) { user in
            UserRow(user: user)
                .onAppear { prefetcher.startPrefetching(urls: nearbyURLs(for: user)) }
                .onDisappear { prefetcher.stopPrefetching(urls: [user.avatarURL]) }
        }
    }
}

With image processing:

swift
CachedAsyncImage(
    url: photo.url,
    processing: .resize(targetSize: CGSize(width: 300, height: 300))
) { image in
    image.resizable()
} placeholder: {
    Color.secondary.opacity(0.2)
}

Testing

swift
@Test
func cachedImageReturnedWithoutDownload() async throws {
    let cache = InMemoryImageCache()
    let downloader = MockImageDownloader()
    let pipeline = ImagePipeline(cache: cache, downloader: downloader)

    let testImage = PlatformImage.testImage
    await cache.store(testImage, for: testURL)

    let result = try await pipeline.image(for: testURL)
    #expect(result != nil)
    #expect(downloader.downloadCount == 0) // Cache hit
}

@Test
func deduplicatesConcurrentRequests() async throws {
    let downloader = MockImageDownloader(delay: .milliseconds(100))
    let pipeline = ImagePipeline(downloader: downloader)

    async let image1 = pipeline.image(for: testURL)
    async let image2 = pipeline.image(for: testURL)

    let results = try await [image1, image2]
    #expect(results.count == 2)
    #expect(downloader.downloadCount == 1) // Only one download
}

References

  • image-loading-patterns.md — Why not AsyncImage, NSCache config, LRU disk cache, deduplication
  • templates.md — All production Swift templates
  • Related: generators/http-cache — General HTTP response caching
  • Related: generators/pagination — Prefetch images in paginated lists

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Image Loading AI skill do?

Generates an image loading pipeline with memory/disk caching, deduplication, and a CachedAsyncImage SwiftUI view. Use when user wants image caching, lazy image loading, or a replacement for AsyncImage.

Why use Image Loading on TypingMind?

Because you install it once and use it with any model. Image Loading is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Image Loading in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/rshankras/claude-code-apple-skills/tree/main/skills/generators/image-loading. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Image Loading?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Image Loading?

As many as you like. As long as a model supports skills, you can use Image Loading with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Image Loading AI skill free?

Yes. It is published on GitHub by rshankras under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇