switch-profile 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -94
- package/dist/cli.js +7921 -0
- package/index.js +12 -409
- package/package.json +31 -25
- package/.eslintrc.json +0 -39
- package/CHANGELOG.md +0 -120
- package/docs/architecture.md +0 -199
- package/docs/aws-profile-management.md +0 -325
- package/docs/cli-interface.md +0 -304
- package/docs/configuration-files.md +0 -240
- package/docs/development-guide.md +0 -168
- package/docs/gotchas.md +0 -82
- package/skills-lock.json +0 -73
- package/src/aws/index.js +0 -574
- package/src/aws/regions.js +0 -103
- package/src/core.js +0 -64
- package/src/fileHelper.js +0 -433
package/docs/gotchas.md
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# Gotchas
|
|
2
|
-
|
|
3
|
-
Critical pitfalls and edge cases that are not immediately obvious when using `switch-profile`.
|
|
4
|
-
|
|
5
|
-
## Table of Contents
|
|
6
|
-
|
|
7
|
-
- [Profile switching is global by default](#profile-switching-is-global-by-default)
|
|
8
|
-
- [The problem](#the-problem)
|
|
9
|
-
- [The solution: `export AWS_PROFILE`](#the-solution-export-aws_profile)
|
|
10
|
-
- [The limitation: you must copy-paste it yourself](#the-limitation-you-must-copy-paste-it-yourself)
|
|
11
|
-
- [LLM agents and automation](#llm-agents-and-automation)
|
|
12
|
-
|
|
13
|
-
## Profile switching is global by default
|
|
14
|
-
|
|
15
|
-
### The problem
|
|
16
|
-
|
|
17
|
-
When you run `npx switch-profile` and select a profile, the tool writes credentials into the `[default]` section of `~/.aws/credentials` and `~/.aws/config`. These are **global files** shared by every terminal, every tool, and every process on the machine.
|
|
18
|
-
|
|
19
|
-
This means:
|
|
20
|
-
- If Terminal A switches to `dev`, Terminal B is now also on `dev`.
|
|
21
|
-
- If Terminal B then switches to `prod`, Terminal A is silently moved to `prod` too.
|
|
22
|
-
- Any concurrent process relying on `[default]` (Terraform, CDK, scripts) is affected immediately.
|
|
23
|
-
|
|
24
|
-
### The solution: `export AWS_PROFILE`
|
|
25
|
-
|
|
26
|
-
After every successful switch, `switch-profile` displays a box like:
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
┌─────────────────────────────────────────────────────────┐
|
|
30
|
-
│ To lock this profile to this terminal session, run: │
|
|
31
|
-
│ │
|
|
32
|
-
│ export AWS_PROFILE=dev │
|
|
33
|
-
│ │
|
|
34
|
-
│ This prevents other terminals from affecting this one. │
|
|
35
|
-
└─────────────────────────────────────────────────────────┘
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Running the displayed command sets an environment variable **scoped to that terminal session only**. The AWS CLI and all AWS SDKs honor `AWS_PROFILE` and will use the named profile directly — bypassing `[default]` entirely. Other terminals remain unaffected.
|
|
39
|
-
|
|
40
|
-
On **Linux / macOS**: `export AWS_PROFILE=dev`
|
|
41
|
-
On **Windows (PowerShell)**: `$env:AWS_PROFILE = "dev"`
|
|
42
|
-
On **Windows (CMD)**: `set AWS_PROFILE=dev`
|
|
43
|
-
|
|
44
|
-
### The limitation: you must copy-paste it yourself
|
|
45
|
-
|
|
46
|
-
`switch-profile` **cannot** set the environment variable for you. This is a fundamental operating system constraint: a child process (the `npx` command) cannot modify the environment of its parent process (your terminal shell). The displayed command (`export` on Unix, `$env:` on PowerShell, `set` on CMD) must be run directly in the terminal by the user.
|
|
47
|
-
|
|
48
|
-
There is no workaround for this within the tool itself. The user must manually copy-paste and run the `export AWS_PROFILE=<name>` command shown after each switch.
|
|
49
|
-
|
|
50
|
-
### LLM agents and automation
|
|
51
|
-
|
|
52
|
-
When an LLM agent (e.g., a Claude Code skill) uses `switch-profile` via a shell tool, the same constraint applies — but with an additional twist.
|
|
53
|
-
|
|
54
|
-
**Environment variables do not persist between shell tool invocations.** Each time an LLM agent runs a Bash command, it spawns a **new shell subprocess**. So even if the agent runs `export AWS_PROFILE=dev` in one command, that variable is gone in the next command.
|
|
55
|
-
|
|
56
|
-
**Workaround:** The agent must prefix every AWS command with the profile inline:
|
|
57
|
-
|
|
58
|
-
```shell
|
|
59
|
-
AWS_PROFILE=dev aws s3 ls
|
|
60
|
-
AWS_PROFILE=dev terraform plan
|
|
61
|
-
AWS_PROFILE=prod aws sts get-caller-identity
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
This works reliably and supports concurrent agents using different profiles, since each command carries its own profile context with no shared global state.
|
|
65
|
-
|
|
66
|
-
**What does NOT work for agents:**
|
|
67
|
-
|
|
68
|
-
```shell
|
|
69
|
-
# Command 1 — sets the variable, but only in this subprocess
|
|
70
|
-
export AWS_PROFILE=dev
|
|
71
|
-
|
|
72
|
-
# Command 2 — this is a NEW subprocess, AWS_PROFILE is not set here
|
|
73
|
-
aws s3 ls # Uses [default], NOT dev
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
**Chaining commands in a single invocation** also works but is less practical for multi-step workflows:
|
|
77
|
-
|
|
78
|
-
```shell
|
|
79
|
-
export AWS_PROFILE=dev && aws s3 ls && aws sts get-caller-identity
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**Summary for skill/agent authors:** After running `npx switch-profile` to authenticate and ensure the SSO session is valid, extract the profile name and use `AWS_PROFILE=<name>` as an inline prefix on every subsequent AWS command.
|
package/skills-lock.json
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockVersion": 1,
|
|
3
|
-
"generatedAt": "2026-03-21T07:51:15.981Z",
|
|
4
|
-
"skills": {
|
|
5
|
-
"happyskillsai/happyskills": {
|
|
6
|
-
"version": "1.17.0",
|
|
7
|
-
"ref": "refs/tags/v1.17.0",
|
|
8
|
-
"commit": "8024d2ee1efd9f17391ebd701a6e6131eafec14777d550e23d3d3a50b5d11439",
|
|
9
|
-
"integrity": "sha256-24e69e779a31ade191ae2fb9dec5a90d28fd9d4afcda2851fc048dd03093c6fb",
|
|
10
|
-
"requested_by": [
|
|
11
|
-
"__root__"
|
|
12
|
-
],
|
|
13
|
-
"dependencies": {}
|
|
14
|
-
},
|
|
15
|
-
"nicolasdao/_kit-dev-essentials": {
|
|
16
|
-
"version": "1.0.0",
|
|
17
|
-
"ref": "refs/tags/v1.0.0",
|
|
18
|
-
"commit": "7c793754d999f50dc44e289b6d190e5f9dc2959e132f62c84625897ced7f95f7",
|
|
19
|
-
"integrity": "sha256-f4fe6b211aa96bbc291c880a4a61682bf5d438a52db0b82e73f42e7126c39e45",
|
|
20
|
-
"requested_by": [
|
|
21
|
-
"__root__"
|
|
22
|
-
],
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"nicolasdao/git-commit": "*",
|
|
25
|
-
"nicolasdao/update-doc": "*",
|
|
26
|
-
"nicolasdao/init-doc": "*",
|
|
27
|
-
"nicolasdao/init-context": "*"
|
|
28
|
-
},
|
|
29
|
-
"type": "kit"
|
|
30
|
-
},
|
|
31
|
-
"nicolasdao/git-commit": {
|
|
32
|
-
"version": "1.0.1",
|
|
33
|
-
"ref": "refs/tags/v1.0.1",
|
|
34
|
-
"commit": "315daee8d9d3ad5e88c42ed35b8e89ccc7ff57bfc28ef0d72ad5122c8e834e19",
|
|
35
|
-
"integrity": "sha256-d7e5a0e9afe9f2633e4e9ad64d8248fca0ee8e20a44f54586474bbfecc79d7e7",
|
|
36
|
-
"requested_by": [
|
|
37
|
-
"nicolasdao/_kit-dev-essentials"
|
|
38
|
-
],
|
|
39
|
-
"dependencies": {}
|
|
40
|
-
},
|
|
41
|
-
"nicolasdao/update-doc": {
|
|
42
|
-
"version": "1.0.4",
|
|
43
|
-
"ref": "refs/tags/v1.0.4",
|
|
44
|
-
"commit": "6394de7f8b487c16700f84d5235a3dca5746205d2abafbdfad02e59bbd924a60",
|
|
45
|
-
"integrity": "sha256-e60d3df49530031a5f663aed8a6999fda6b4caab4deba249ec7cfd5ec65f085c",
|
|
46
|
-
"requested_by": [
|
|
47
|
-
"nicolasdao/_kit-dev-essentials"
|
|
48
|
-
],
|
|
49
|
-
"dependencies": {}
|
|
50
|
-
},
|
|
51
|
-
"nicolasdao/init-doc": {
|
|
52
|
-
"version": "0.1.1",
|
|
53
|
-
"ref": "refs/tags/v0.1.1",
|
|
54
|
-
"commit": "9603e12aa7dba8c2d6903f249a60b418f3913c94dddfde266e065d1b9bbd0171",
|
|
55
|
-
"integrity": "sha256-567e6e55d27b9873bf1664bd7992cc8d3b7045e4d371de136245e5193e04b680",
|
|
56
|
-
"requested_by": [
|
|
57
|
-
"nicolasdao/_kit-dev-essentials"
|
|
58
|
-
],
|
|
59
|
-
"dependencies": {},
|
|
60
|
-
"type": "skill"
|
|
61
|
-
},
|
|
62
|
-
"nicolasdao/init-context": {
|
|
63
|
-
"version": "1.0.1",
|
|
64
|
-
"ref": "refs/tags/v1.0.1",
|
|
65
|
-
"commit": "a52d089f1c6a102feac17b99e7df72e29899952f393013bd479e3f97cc614f32",
|
|
66
|
-
"integrity": "sha256-417c5dc3e0b59f785fd8af166bbaa757f4bfac8343d7365708342e84d386bd01",
|
|
67
|
-
"requested_by": [
|
|
68
|
-
"nicolasdao/_kit-dev-essentials"
|
|
69
|
-
],
|
|
70
|
-
"dependencies": {}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|