background-processing skill
Generates background processing infrastructure including BGTaskScheduler, background URLSession downloads, and silent push notification handling.
- GitHub stars
- 882
- Files
- 2
- Last commit
- Nov 9, 2026
- License
- MIT
- Allowed tools
- 7
What does the background-processing skill do?
background-processing generates background processing infrastructure including BGTaskScheduler, background URLSession downloads, and silent push notification handling.
Summary generated from the skill's SKILL.md.
About the background-processing skill
Developers building iOS or macOS applications can use this skill to implement complex background execution logic. It automates the creation of infrastructure for periodic app refreshes, long-running data processing, and file transfers that continue even after an app is closed. The tool generates specific Swift files like BackgroundTaskManager.swift and BackgroundDownloadManager.swift to handle these lifecycle events.
An agent should load this skill when a user needs to sync data, update ML models, or manage background URLSession downloads. The process begins by scanning the existing project for BGTaskScheduler usage and checking Info.plist configurations or entitlements. It then produces a structured directory containing managers for task registration, configuration constants, and handlers for silent push notifications. This ensures that background tasks are registered correctly during the app launch sequence to avoid silent failures.
What an agent can do with it
- 1Implement periodic app refreshesAdd lightweight background updates for content like weather or news feeds.
- 2Manage large file transfersSet up background downloads and uploads that survive app termination.
- 3Handle server-triggered updatesConfigure silent push notification handling to update app content via remote triggers.
- 4Execute long-running data tasksCreate infrastructure for heavy operations like database cleanup or model updates.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the background-processing skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the background-processing skill in Claude Code
~/.claude/skills/background-processing/SKILL.md
$ npx degit rshankras/claude-code-apple-skills/skills/generators/background-processing ~/.claude/skills/background-processingInstall the background-processing skill in Claude Code (project)
.claude/skills/background-processing/SKILL.md
$ npx degit rshankras/claude-code-apple-skills/skills/generators/background-processing .claude/skills/background-processingInstall the background-processing skill in Codex
~/.agents/skills/background-processing/SKILL.md
$ npx degit rshankras/claude-code-apple-skills/skills/generators/background-processing ~/.agents/skills/background-processingInstall the background-processing skill in Gemini CLI
~/.gemini/skills/background-processing/SKILL.md
$ npx degit rshankras/claude-code-apple-skills/skills/generators/background-processing ~/.gemini/skills/background-processingInstall the background-processing skill in Claude.ai
npx degit rshankras/claude-code-apple-skills/skills/generators/background-processing background-processing && zip -r background-processing.zip background-processing # claude.ai → Customize → Skills → + → Create skill → Upload a skill → background-processing.zip
Automated checks
Ran Nov 15, 2026Full report →Not verified yet. A skill needs a score of 80, no serious finding, and enough data for us to check. How checks work · What to fix for more points
- Source repository linked and reachablershankras/claude-code-apple-skills/skills/generators/background-processing is public and reachablegithub.com/rshankras/claude-code-apple-skills/tree/HEAD/skil ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-09github.com/rshankras/claude-code-apple-skills/commits ↗Pass
- No download-and-run or credential theft in scriptsNo scripts in the skill folderPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/rshankras/claude-code-apple-skills/blob/HEAD/skil ↗Pass
- Pre-approved tools are scopedBash lets the agent run any shell command without askinggithub.com/rshankras/claude-code-apple-skills/blob/HEAD/skil ↗Finding
- SKILL.md follows the Agent Skills formatValid name and description; says when to use it; 266 linesgithub.com/rshankras/claude-code-apple-skills/blob/HEAD/skil ↗Pass
SKILL.md
View on GitHubBackground Processing Generator
Generate production background processing infrastructure -- BGTaskScheduler for periodic refresh and long-running tasks, background URLSession for downloads/uploads that survive app termination, and silent push handling for server-triggered updates.
When This Skill Activates
Use this skill when the user:
- Asks to "add background processing" or "background tasks"
- Mentions "BGTaskScheduler" or "BGAppRefreshTask" or "BGProcessingTask"
- Wants "background refresh" or "periodic background updates"
- Asks about "background downloads" or "background uploads"
- Mentions "silent push" or "content-available push notifications"
- Wants data to sync or update while the app is in the background
- Asks about "background fetch" or "background execution"
Pre-Generation Checks
1. Project Context Detection
- Check deployment target (BGTaskScheduler requires iOS 13+)
- Check Swift version (requires Swift 5.9+)
- Check for @Observable support (iOS 17+ / macOS 14+)
- Identify source file locations
2. Existing Background Task Detection
Search for existing background task code:
Glob: **/*BackgroundTask*.swift, **/*BGTask*.swift, **/*BackgroundDownload*.swift
Grep: "BGTaskScheduler" or "BGAppRefreshTask" or "BGProcessingTask" or "backgroundSession"
If existing background code found:
- Ask if user wants to replace or augment it
- If augmenting, identify what is missing and generate only those pieces
3. Info.plist Check
Search for existing background modes configuration:
Grep: "BGTaskSchedulerPermittedIdentifiers" or "UIBackgroundModes"
Check for push notification entitlements if silent push is needed:
Glob: **/*.entitlements
Grep: "aps-environment"
Configuration Questions
Ask user via AskUserQuestion:
-
What background processing do you need?
- App refresh (lightweight periodic updates -- weather, feeds, content)
- Data processing (long-running -- database cleanup, ML model updates, large syncs)
- Background downloads (files, media, assets that survive app termination)
- Silent push notifications (server-triggered content updates)
- Multiple (select which combination)
-
How often should background tasks run?
- Hourly (system decides exact timing, best-effort)
- Every few hours (recommended for most apps)
- Daily (content that changes infrequently)
- On content change via push (server triggers update with silent push)
-
Does the task need network access?
- Yes -- needs background fetch or download capability
- No -- local processing only (database maintenance, cleanup)
Generation Process
Step 1: Read Templates
Read templates.md for production Swift code.
Step 2: Create Core Files
Generate these files:
BackgroundTaskManager.swift-- Central manager for registering and scheduling all background tasksBackgroundTaskConfiguration.swift-- Info.plist keys, entitlements, and task identifier constants
Step 3: Create Feature-Specific Files
Based on configuration:
3. BackgroundDownloadManager.swift -- If background downloads selected
4. SilentPushHandler.swift -- If silent push selected
Step 4: Determine File Location
Check project structure:
- If
Sources/exists ->Sources/BackgroundProcessing/ - If
App/exists ->App/BackgroundProcessing/ - Otherwise ->
BackgroundProcessing/
Output Format
After generation, provide:
Files Created
BackgroundProcessing/
├── BackgroundTaskManager.swift # BGTaskScheduler registration & scheduling
├── BackgroundTaskConfiguration.swift # Task identifiers and Info.plist config
├── BackgroundDownloadManager.swift # Background URLSession downloads (optional)
└── SilentPushHandler.swift # Silent push handling (optional)
Integration with App Lifecycle
Register tasks at app launch (must happen before app finishes launching):
@main
struct MyApp: App {
@UIApplicationDelegateAdaptor private var appDelegate: AppDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
BackgroundTaskManager.shared.registerTasks()
return true
}
}
Schedule refresh when app enters background:
struct ContentView: View {
@Environment(\.scenePhase) private var scenePhase
var body: some View {
NavigationStack {
FeedView()
}
.onChange(of: scenePhase) { _, newPhase in
if newPhase == .background {
BackgroundTaskManager.shared.scheduleAppRefresh()
}
}
}
}
Start a background download:
func downloadAsset(from url: URL) {
BackgroundDownloadManager.shared.startDownload(from: url)
}
Handle silent push in AppDelegate:
func application(
_ application: UIApplication,
didReceiveRemoteNotification userInfo: [AnyHashable: Any]
) async -> UIBackgroundFetchResult {
await SilentPushHandler.shared.handle(userInfo: userInfo)
}
Testing
Simulate background task in Xcode debugger (LLDB):
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateLaunchForTaskWithIdentifier:@"com.app.refresh"]
Simulate expiration:
e -l objc -- (void)[[BGTaskScheduler sharedScheduler] _simulateExpirationForTaskWithIdentifier:@"com.app.refresh"]
Test background download:
#if DEBUG
func simulateBackgroundDownload() {
let testURL = URL(string: "https://example.com/test-asset.zip")!
BackgroundDownloadManager.shared.startDownload(from: testURL)
}
#endif
Required Info.plist Configuration
Add to Info.plist:
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.app.refresh</string>
<string>com.app.processing</string>
</array>
Required Background Modes
In Xcode: Target > Signing & Capabilities > Background Modes:
- Background fetch -- for BGAppRefreshTask
- Background processing -- for BGProcessingTask
- Remote notifications -- for silent push
- Background download -- for background URLSession (automatic when using background configuration)
Common Patterns
Schedule Refresh on Entering Background
Always schedule the next refresh when the app goes to background. The system decides when to actually run it.
BackgroundTaskManager.shared.scheduleAppRefresh()
Long-Running Processing with Expiration Handling
BGProcessingTask can run for minutes, but always handle the expirationHandler to save progress.
task.expirationHandler = {
// Save partial progress so next run can resume
processingJob.saveCheckpoint()
}
Energy-Efficient Background Work
// Only process on Wi-Fi + power
let request = BGProcessingTaskRequest(identifier: taskID)
request.requiresNetworkConnectivity = true
request.requiresExternalPower = true
Gotchas
Registration Must Happen Before didFinishLaunching Returns
BGTaskScheduler.shared.register(forTaskWithIdentifier:) must be called during didFinishLaunchingWithOptions. If called later, the registration silently fails. Always register in AppDelegate, never in a View.
System Controls Scheduling
The system decides when to run background tasks based on battery, network, user patterns, and frequency. You cannot guarantee exact timing. earliestBeginDate is a hint, not a guarantee.
Background URLSession Delegate Callbacks
Background URLSession delivers delegate callbacks even if the app was terminated and relaunched. The session must be recreated with the same identifier, and application(_:handleEventsForBackgroundURLSession:completionHandler:) must be implemented.
Silent Push Limitations
Silent push notifications are rate-limited by APNs. If you send too many, the system throttles them. Use them for important content changes, not periodic polling.
30-Second Window for App Refresh
BGAppRefreshTask gives you approximately 30 seconds of execution time. For longer work, use BGProcessingTask instead (which can run for several minutes when conditions are met).
Simulator Limitations
Background tasks do not run naturally on the Simulator. Use the LLDB _simulateLaunchForTaskWithIdentifier: command to trigger them manually during development.
References
- templates.md -- All production Swift templates for background processing
- Background Tasks Framework
- Downloading Files in the Background
- Pushing Background Updates to Your App
- Related:
generators/push-notifications-- Full push notification infrastructure - Related:
generators/offline-queue-- Queue operations for when back online
Files in this skill
2background-processing skill questions
How do I install the background-processing skill in Claude Code?
Run npx degit rshankras/claude-code-apple-skills/skills/generators/background-processing ~/.claude/skills/background-processing. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the background-processing skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
How can I test background tasks in the simulator?
You can simulate background tasks in the Xcode debugger using LLDB commands like _simulateLaunchForTaskWithIdentifier:.