Skip to main content
skill CX Codex

hf-cloud-aws-context-discovery — Claude Code skill

This skill resolves the active AWS profile, region, account, and caller ARN before AWS work. It helps agents use local configuration instead of guessing.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add huggingface/skills --skill hf-cloud-aws-context-discovery -a claude-code
Open on GitHub

What hf-cloud-aws-context-discovery does

The skill reads the local AWS setup before deployments, resource creation, AWS API calls, or any task that touches an account. It resolves the active profile, region, account ID, and caller ARN, then keeps those values available for the rest of the session.

It uses aws configure list and aws sts get-caller-identity, while accounting for AWS_PROFILE, AWS_REGION, AWS_DEFAULT_REGION, ~/.aws/config, and ~/.aws/credentials. Region lookup follows an explicit user value, environment variables, and the active profile. There is no hardcoded fallback region.

The skill also identifies SSO and assumed-role principals from the ARN. For SSO, it warns that IAM role creation is usually unavailable, so a SageMaker task should look for an existing role first. That is a reason to check permissions before deployment, since the failure may otherwise appear at iam:CreateRole.

What it helps with

  • resolve the active AWS profile and region
  • validate credentials through AWS STS
  • retrieve the account ID and caller ARN
  • identify SSO or assumed-role access before deployment
  • prevent an incorrect region from being guessed

Example prompts for the agent

  • Before deploying to AWS, discover the profile, region, and account ID from my local configuration.
  • Check my AWS context before calling an AWS API and report the caller ARN.
  • Before creating a SageMaker role, determine whether I am authenticated through SSO and flag IAM limits.

How to install hf-cloud-aws-context-discovery

1Skills CLI (Vercel)

npx skills add huggingface/skills --skill hf-cloud-aws-context-discovery -a claude-code

2Manually: put the files in place

~/.claude/skills/hf-cloud-aws-context-discovery/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/hf-cloud-aws-context-discovery/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about hf-cloud-aws-context-discovery

How do I install hf-cloud-aws-context-discovery in Claude Code?

Run npx skills add huggingface/skills --skill hf-cloud-aws-context-discovery -a claude-code, then run npx skills add huggingface/skills --skill hf-cloud-aws-context-discovery -a claude-code again. The skill file is at ~/.claude/skills/hf-cloud-aws-context-discovery/SKILL.md.

What does hf-cloud-aws-context-discovery do?

It reads the AWS profile and region, validates credentials through STS, and returns the account ID and caller ARN. It also detects SSO access and warns about likely IAM limits.

What happens when no AWS region is configured?

The skill checks an explicit user value, AWS_REGION, AWS_DEFAULT_REGION, and the active profile. When all four produce no region, it asks the user instead of falling back to us-east-1.

Source text

SKILL.md · Apache-2.0
---
name: hf-cloud-aws-context-discovery
description: Discover the user's local AWS context (active profile, region, account ID, caller identity) at the start of any AWS task. Use this skill before any other AWS work — deploying to SageMaker, creating resources, calling AWS APIs, or anything that touches an AWS account. Use it especially when the user has not specified a region or profile explicitly, when they say things like "use my AWS account", "deploy to AWS", "use my profile", or when about to make any AWS CLI or SDK call. Never guess the region or account ID — always use this skill to read it from the local configuration first.
---

# AWS Context Discovery

Before doing any AWS work, read the user's local AWS config. Don't guess the region, and don't ask the user for things their config already answers.

## What to discover

Run these at the start of the AWS work and remember the results for the rest of the session.

### 1. Active profile

`AWS_PROFILE` env var, else `default`. If the user mentioned a profile in their prompt, that overrides. If the named profile doesn't exist in `~/.aws/config`, surface that clearly.

### 2. Region

Resolution order — stop at the first one that produces a value:
1. Region the user explicitly named in this conversation
2. `AWS_REGION` env var
3. `AWS_DEFAULT_REGION` env var
4. `region` field on the active profile in `~/.aws/config`
5. Ask the user — but only after the first four have failed

Do not fall back to `us-east-1` or any other hardcoded default.

### 3. Credentials, account ID, caller ARN

```bash
aws sts get-caller-identity --profile <profile> --region <region>
```

Three purposes in one call: confirms credentials are valid (stop if not), returns the `Account` ID (needed for ARN construction), returns the `Arn` of the caller.

### 4. Identify SSO / assumed-role principals

The `Arn` field tells you what kind of principal this is. The pattern matters because it determines what IAM operations the caller can do.

| ARN pattern | Type | IAM write capability |
|---|---|---|
| `arn:aws:iam::<acct>:user/<name>` | IAM user | Depends on attached policies |
| `arn:aws:sts::<acct>:assumed-role/AWSReservedSSO_<...>/<email>` | **SSO assumed-role** | Typically **none** — can't create/modify IAM roles |
| `arn:aws:sts::<acct>:assumed-role/<role>/<session>` | Regular assumed-role | Depends on the role |

**If the caller is SSO**, surface this immediately before later skills hit `iam:CreateRole` and fail:

> Heads up: you're authenticated via SSO (`AWSReservedSSO_<PermissionSet>_...`). SSO principals usually can't create IAM roles directly. If we need a SageMaker execution role, I'll look for an existing one first — if none exists, you'll need to ask whoever manages your AWS access to create one.

This is the highest-leverage thing this skill does. Surfacing it now turns a confusing mid-deployment error into a five-second conversation.

## Commands to run

```bash
# Effective profile and region (faster than parsing config files)
aws configure list

# Validate credentials and get identity
aws sts get-caller-identity
aws sts get-caller-identity --profile <profile-name>  # if a profile was named
```

`aws configure list` handles env-var overrides and shows the resolved effective values. Prefer it over parsing `~/.aws/config` yourself. If you need to read raw config (e.g. to list profiles), `~/.aws/config` and `~/.aws/credentials` are plain INI files — read-only.

## What to report back

One or two lines, not a wall of text:

> Working with profile `my-profile` in `eu-west-1`, account `123456789012`. You're authenticated via SSO, so we'll need to use an existing IAM role rather than create one.

Don't ask the user to confirm the region you just read from their config — they configured it; that is the confirmation.

If something is wrong (credentials expired, profile doesn't exist, no region anywhere), stop and surface the specific error before continuing.

© huggingface · Apache-2.0 · huggingface/skills

Similar skills

Everything for Cloud: AWS, Azure, GCP →

From the same set25

hf-mem Estimates the memory a Hugging Face model needs for inference without downloading the weights. Useful before you commit a GPU to a model. CX Codex +1 858installs huggingface-lora-space-builder Builds and publishes Gradio demos on Hugging Face Spaces for LoRA checkpoints. Tailors diffusers pipelines and UI inputs, targeting ZeroGPU hardware by default. CX Codex +1 810installs hf-cloud-sagemaker-production-defaults This skill creates SageMaker endpoints with autoscaling, CloudWatch alarms, and tags. Use it for the final model deployment step. CX Codex +1 549installs hf-cloud-python-env-setup Configures an isolated Python environment for AWS and SageMaker automation. It ensures compatible Python versions and installs up-to-date boto3 to avoid API mismatches. CX Codex +1 548installs hf-cloud-sagemaker-deployment-planner Picks a deployment pathway for a model on Amazon SageMaker: real-time, async, serverless or batch. Useful once training is done and the endpoint still isn't decided. CX Codex +1 544installs hf-cloud-serving-image-selection Picks the serving container for a SageMaker model deployment and finds its current image URI. Useful whenever deployment code needs an image. CX Codex +1 544installs hf-cloud-sagemaker-iam-preflight Validates or discovers a usable SageMaker execution role before deployment or training. Prevents AccessDenied failures on SSO credentials. CX Codex +1 542installs huggingface-skills A pack of skills for training models, handling datasets and launching Spaces from your coding agent. Useful if your work lives on the Hugging Face Hub. ★ 11,213repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor