cc-aws-keepalive banner
GeiserX GeiserX

cc-aws-keepalive

DevOps community intermediate

Description

Keep Claude Code sessions alive through AWS credential expiration. No more restarting terminal tabs every time your SSO/SAML session expires.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

cc-aws-keepalive

Keep Claude Code sessions alive through AWS credential expiration. No more restarting terminal tabs every time your SSO/SAML session expires.

Problem

When using Claude Code with AWS Bedrock, the AWS SDK caches credentials in memory. After your SSO/SAML session expires (typically every 8-12 hours), all Claude Code sessions become unresponsive and must be restarted — often corrupting conversations and losing context.

Solution

Four Node.js scripts (cross-platform: macOS, Linux, Windows) that hook into Claude Code's credential lifecycle:

Script Purpose CC Setting
aws-cred-export.mjs Reads fresh creds from ~/.aws/credentials, bypassing SDK in-memory cache awsCredentialExport
aws-auth-refresh.mjs On auth failure, checks if you already re-authed in another terminal awsAuthRefresh
aws-cred-check.mjs Proactive check before each prompt — warns if expired or nearing expiry hooks.UserPromptSubmit
aws-statusline.mjs Optional persistent timer in the status bar (e.g., AWS: 4h23m) statusLine

How it works

**Before expiry (proactive):**

  1. You submit a prompt in Claude Code
  2. The UserPromptSubmit hook checks credential expiration
  3. If nearing expiry: inline warning with re-auth instructions
  4. If expired: warns inline — the prompt proceeds and awsAuthRefresh handles recovery

**After expiry (reactive):**

  1. Claude Code hits a Bedrock 403
  2. awsAuthRefresh runs — checks if you already re-authed in another terminal
  3. awsCredentialExport reads fresh creds from disk (bypassing SDK memory cache)
  4. Claude Code retries the API call — session continues without restart

The key insight

...