From flyio-pack
Provides typed clients and lifecycle patterns for Fly.io Machines API with multi-region deployment orchestration. Useful for managing machine state and deployments.
How this skill is triggered — by the user, by Claude, or both
Slash command
/flyio-pack:flyio-sdk-patternsThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Production-ready patterns for the Fly.io Machines REST API at `https://api.machines.dev`. Typed client, machine lifecycle management, wait-for-state patterns, and multi-region orchestration.
Production-ready patterns for the Fly.io Machines REST API at https://api.machines.dev. Typed client, machine lifecycle management, wait-for-state patterns, and multi-region orchestration.
const FLY_API = 'https://api.machines.dev';
interface FlyMachine {
id: string;
name: string;
state: 'created' | 'starting' | 'started' | 'stopping' | 'stopped' | 'destroying' | 'destroyed';
region: string;
config: {
image: string;
guest: { cpu_kind: string; cpus: number; memory_mb: number };
services: Array<{ ports: Array<{ port: number; handlers: string[] }>; internal_port: number }>;
env: Record<string, string>;
};
}
class FlyClient {
private headers: Record<string, string>;
constructor(private appName: string, token: string) {
this.headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' };
}
async listMachines(): Promise<FlyMachine[]> {
const res = await fetch(`${FLY_API}/v1/apps/${this.appName}/machines`, { headers: this.headers });
return res.json();
}
async createMachine(config: FlyMachine['config'], region: string): Promise<FlyMachine> {
const res = await fetch(`${FLY_API}/v1/apps/${this.appName}/machines`, {
method: 'POST', headers: this.headers,
body: JSON.stringify({ region, config }),
});
return res.json();
}
async stopMachine(id: string): Promise<void> {
await fetch(`${FLY_API}/v1/apps/${this.appName}/machines/${id}/stop`, {
method: 'POST', headers: this.headers,
});
}
async waitForState(id: string, state: string, timeout = 30): Promise<void> {
await fetch(
`${FLY_API}/v1/apps/${this.appName}/machines/${id}/wait?state=${state}&timeout=${timeout}`,
{ headers: this.headers },
);
}
}
async function deployToRegions(client: FlyClient, regions: string[], config: FlyMachine['config']) {
const machines = await Promise.all(
regions.map(async region => {
const machine = await client.createMachine(config, region);
await client.waitForState(machine.id, 'started');
console.log(`Machine ${machine.id} started in ${region}`);
return machine;
})
);
return machines;
}
// Deploy to 3 regions
await deployToRegions(client, ['iad', 'lhr', 'nrt'], {
image: 'registry.fly.io/my-app:latest',
guest: { cpu_kind: 'shared', cpus: 1, memory_mb: 256 },
services: [{ ports: [{ port: 443, handlers: ['tls', 'http'] }], internal_port: 3000 }],
env: { NODE_ENV: 'production' },
});
async function blueGreenDeploy(client: FlyClient, newImage: string) {
const oldMachines = await client.listMachines();
// Create new machines with updated image
const newMachines = await Promise.all(
oldMachines.map(m => client.createMachine(
{ ...m.config, image: newImage },
m.region,
))
);
// Wait for all new machines to be healthy
await Promise.all(newMachines.map(m => client.waitForState(m.id, 'started')));
// Stop old machines
await Promise.all(oldMachines.map(m => client.stopMachine(m.id)));
console.log(`Blue-green: ${newMachines.length} new, ${oldMachines.length} stopped`);
}
Apply patterns in flyio-core-workflow-a for real-world usage.
2plugins reuse this skill
First indexed Jul 17, 2026
npx claudepluginhub kriptoburak/jeremylongshore-claude-code-plugins-plus-skills --plugin flyio-packProvides typed FlyClient patterns for the Fly.io Machines REST API: machine lifecycle management, auth, error handling with retry, and multi-region orchestration.
Deploy, configure, and manage applications on the Fly.io platform using flyctl CLI, fly.toml configuration, Fly Machines, Fly Volumes, private networking, secrets, health checks, autoscaling, and GitHub Actions CI/CD. Use when deploying any application to Fly.io, writing or modifying fly.toml configuration, managing Fly Machines or Volumes, configuring networking (public services, private 6PN, Flycast, custom domains, TLS), setting secrets, configuring health checks, setting up autostop/autostart or metrics-based autoscaling, deploying with GitHub Actions, managing Fly Postgres databases, or preparing an app for production on Fly.io.
Deploys and manages Fly.io apps using Docker containers, Fly Machines, fly.toml configs, databases, volumes, secrets. Supports fly launch/deploy, debugging, multi-region setups for Python/Node/Rails/Django apps.