Have Claude Code Create Commands for You

Article Highlights

  • Claude Code skills and commands both use a SKILL.md file; the key difference is whether Claude invokes the file automatically or you run it explicitly.
  • A reusable command can install Microsoft Dev Proxy, add MSAL authentication code, define invocation triggers, and provide start and stop instructions.
  • The most reliable way to build a complex command is to extend it through focused prompts, test it against a real application, and debug it iteratively.
  • Fixes discovered during testing should be applied to the command rather than to one application so every future project benefits.

Claude Code commands for reusable Dev Proxy and MSAL setup

Skills vs. Commands

If you ever use the same prompt twice when working with Claude Code, you should be creating a command. And, just like having Claude Code write your application code, you should have Claude Code write your command for you.

In this post, I’m going to walk through creating a command to do three things you need in every Azure project:

  • Add a mock version of Entra ID to your development computer

  • Add to your application the authentication/authorization code to work with Entra ID

  • Manage that mock version of Entra ID after it’s installed

I’ve thrown in that command at the end of this post. And, by the way, this process works just as well for creating Claude Code skills so it’s worth explaining why that is before I start.

As Learning Tree’s Leveraging Claude Code in Application Development course points out, Claude Code skills and commands are both implemented by creating a SKILL.md file. The only difference between a “skill” and “command” is how they are invoked, not how they are built: If your SKILL.md file is invoked automatically by Claude then it’s called a skill; If you invoke your SKILL.md from Claude’s CLI by typing a forward slash (e.g. /MySkill), then it’s a command.

SKILLS VS. COMMANDS

Same file. Different trigger.

A skill and a command are both a SKILL.md file. What changes is who pulls the trigger.

SKILL.md

SKILL

Claude decides.

Claude runs the file when your request matches its description.

you › set up mock authclaude › runs my-skill
---name: my-skilldescription: what it does, when to use it---

COMMAND

You decide.

You run the file yourself by typing a forward slash and its name.

you › /my-skillRuns only when you ask.
---name: my-skilldisable-model-invocation: true---

Delete one line, disable-model-invocation, and a command becomes a skill.

If you have a SKILL.md file that you intend to use exclusively as a command, then you can omit the description property in the SKILL.md file’s frontmatter and add disable-model-invocation: true to that frontmatter.

This would be a perfectly acceptable way to begin a “command only” SKILL.md file, for example:

---

name: my-skill

disable-model-invocation: true

---

Though, I have to say, omitting the description property means giving up an opportunity to make your command a little more self-documenting. Just because you can do something, doesn’t mean you should do something.

Mocking and Accessing Entra ID

I do a lot of Azure development (I’m currently building an application to run in Azure and support people taking certification exams, for example) but I don’t want to interact with Azure resources while I’m building my application. There are two reasons for that: First, it’s faster for me to build things if everything is executing on my own computer; Second, It’s cheaper (my primary reason).

But to avoid using Azure, I need to emulate Azure resources my development computer, including Entra ID so that I can test my application’s MSAL authorization and authentication code. Microsoft has an emulator that does that, called Microsoft Dev Proxy.

Dev Proxy gives any MSAL code that I add to my application something to interact with so that I can make sure that that my code works. I can’t create identities and roles with Dev Proxy (I have to wait until I move to Azure to do that) but Dev Proxy will check that my application is making valid authentication requests (including requests to services like Microsoft Graph and LLMs: see https://learn.microsoft.com/en-us/microsoft-cloud/dev/dev-proxy/how-to/overview for more information).

Adding Dev Proxy to your computer isn’t hard to do. This PowerShell command will do it in Windows:

iwr https://aka.ms -useb | iex

And this Bash command will do it in Linux or macOS:

sh -c "$(curl -sL https://aka.ms)"

On the other hand, writing the MSAL code to have your application authenticated and authorized isn’t trivial. Fortunately, that code is pretty much the same in every application: The only thing that changes from one application to another is the security information you pass to your MSAL code – and that information is best kept in environment variables in production or in User Secrets in development. If you want to see the ugly details of that code, I have a blog post on securing client-side frontends and another on securing server-side frontends.

Building a Command with Claude

You can certainly ask Claude Code to add your MSAL code for you. However, since the MSAL code is pretty much identical from one application to another, you’ll end up using the same prompt every time – which means this is a perfect opportunity to create a command. And, while you’re doing that, you can have your command both install Dev Proxy (if it isn’t already installed) and let you manage Dev Proxy once it’s installed.

BUILDING THE COMMAND

Four prompts. One command.

Claude Code wrote the command. Each prompt switched on one more capability in the same file.

01

Create a command that sets up Microsoft Dev Proxy v3 for a React + TypeScript SPA with MSAL authentication…

+ InstallMSAL codeTriggersStart / stop

02

Add to the skill all the necessary MSAL code to authorize my application…

Install+ MSAL codeTriggersStart / stop

03

The skill should run on any mention of “dev proxy”, “mock auth”, “mock Entra”…

InstallMSAL code+ TriggersStart / stop

04

Include commands for starting and stopping Dev Proxy from the CLI.

InstallMSAL codeTriggers+ Start / stop

✓ SKILL.md installs, wires up and manages Dev Proxy.

If you look at the end of this post, you’ll see that command. You may even be impressed with my coding abilities as you read it…except I didn’t write that command – Claude Code did. Claude Code can write the markdown for your skills and commands as easily as it will write the code for your application.

The initial prompt for my Dev Proxy/MSAL command for my client-side code looked like this:

Create a command that sets up Microsoft Dev Proxy v3 for a React + TypeScript SPA with MSAL authentication. Check for Dev Proxy version 3.0.0 or later in this computer and, if older, install the most recent version.

After that prompt, my next step was to have Claude Code extend the command to add MSAL authentication/authorization code to my application. This prompt barely refers to Dev Proxy: I want the command to add the code that my application will use in production – it just happens to interact with Dev Proxy while I’m in development:

Add to the skill all the necessary MSAL code to authorize my application. Use the application’s URL and create dummy tenant and client ids in a configuration file. Generate any Dev Proxy configuration files required for authentication in development.

Next, I specified when this command should be invoked so I didn’t have to use the forward slash to execute it:

The skill should run on any mention of "dev proxy", "devproxy", "mock auth", "mock Entra", "MSAL proxy", or any request to intercept Entra/Azure AD auth locally without a real tenant.

And, what the heck, as long as I was at, I had the command start and stop Dev Proxy for me:

Include commands for starting and stopping Dev Proxy from the CLI.

I then tried using my command. Did it work? Don’t be silly – no, of course it didn’t. Nothing works the first time.

Among other issues, there were some holes in Microsoft’s Dev Proxy documentation that Claude Code didn’t spot…the first time it wrote the command. But just like writing application code, I used Claude Code interactively to debug my command and tell me what went wrong. During this part of the process, my cycle was to tell Claude Code to:

  1. Back out any changes made to my application made while testing the command

  2. Apply any fixes to the command (not to my application code), based on what we discovered during testing

And then Claude Code and I repeated that process until we had a working command.

Using Commands

I’ll repeat what I said at the start of this post: If you find yourself using the same prompt twice in building with Claude Code then you should get Claude Code to create a command for you. And because commands are also skills, you don’t have to stop there. I built some more commands to add the other Azure emulators I use (e.g. the emulators functions and Azure Storage) and let me manage those emulators also. Eventually, I stripped out the “disable model” property to turn those commands into skills. That let me create plugin for setting up and managing my Azure development environment.

DEBUGGING THE COMMAND

Nothing works the first time.

So debug the command the way you debug code: in a loop.

while (!command.works) {

01

Run it

Try the command against a real application.

02

Ask why

Have Claude Code tell you what went wrong.

03

Back out

Undo everything the test run changed in your application.

04

Fix the command

Put the fix in the command, not in your application code.

} // ↻ back to 01

A fix in the application helps once. A fix in the command helps every project that uses it.

You should be getting Claude to do the same for you.

The Claude Command’s SKILL.md file.

---

name: dev-proxy

description: Sets up Microsoft Dev Proxy v3 for a React + TypeScript SPA with MSAL authentication.

When invoked, writes devproxyrc.json, entra-mocks.json, and api-mocks.json, and wires MSAL (@azure/msal-browser + @azure/msal-react) into the application entry point and auth component. Use on any mention of "dev proxy", "devproxy", "mock auth", "mock Entra", "MSAL proxy", or any request to intercept Entra/Azure AD auth locally without a real tenant. Also provides commands for starting and stopping Dev Proxy from the CLI.

---

# Dev Proxy v3 + MSAL Setup Skill

When this skill is invoked, perform every numbered step below in order. Infer configuration values from context (CLAUDE.md, vite.config.ts, existing authConfig.ts, package.json) wherever possible. Ask the user only for information you cannot determine yourself. Also watch for the user to start and stop Dev Proxy from the CLI, and provide instructions as needed.

---

## Step 0 — Locate the web app

Identify the React/TypeScript project root: the directory that contains (or will contain)`package.json` and the Dev Proxy files. If there are multiple web projects in the solution,ask the user which one to configure.

---

## Step 1 — Collect configuration values

| Variable | Where to look | Default / fallback |

|---|---|---|

| `APP_URL` | `vite.config.ts` server.port, existing authConfig.ts redirectUri | Ask user |

| `API_URL` | Vite proxy config, CLAUDE.md architecture section | Ask user |

| `TENANT_ID` | Existing authConfig.ts | `aaaabbbb-cccc-dddd-eeee-ffffaaaabbbb` |

| `CLIENT_ID` | Existing authConfig.ts | `11112222-3333-4444-5555-666677778888` |

The default TENANT_ID and CLIENT_ID are dummy GUIDs — no real Azure tenant or app registration is required. Dev Proxy intercepts all calls to login.microsoftonline.com.

---

## Step 2 — Install MSAL packages

If `@azure/msal-browser` and `@azure/msal-react` are not already in `package.json`:

```powershell

npm install @azure/msal-browser @azure/msal-react

```

---

## Step 3 — Write devproxyrc.json

Write to the web app root, substituting `API_URL` and `TENANT_ID`/`CLIENT_ID`:

```json

{

"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/rc.schema.json",

"urlsToWatch": [

"https://login.microsoftonline.com/*",

"API_URL/*"

],

"plugins": [

{

"name": "EntraMockResponsePlugin",

"enabled": true,

"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",

"configSection": "entraMocksPlugin"

},

{

"name": "MockResponsePlugin",

"enabled": true,

"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",

"configSection": "apiMocksPlugin"

},

{

"name": "AuthPlugin",

"enabled": true,

"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",

"configSection": "auth"

}

],

"entraMocksPlugin": {

"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.schema.json",

"mocksFile": "entra-mocks.json"

},

"apiMocksPlugin": {

"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.schema.json",

"mocksFile": "api-mocks.json",

"blockUnmockedRequests": false

},

"auth": {

"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/authplugin.schema.json",

"type": "oauth2",

"oauth2": {

"metadataUrl": "https://login.microsoftonline.com/TENANT_ID/v2.0/.well-known/openid-configuration",

"allowedAudiences": ["api://CLIENT_ID"],

"allowedApplications": ["CLIENT_ID"],

"validateSigningKey": false,

"validateLifetime": false

}

}

}

```

---

## Step 4 — Write entra-mocks.json

Write to the web app root, substituting `APP_URL` and `CLIENT_ID`.

### Four rules that the Dev Proxy documentation gets wrong

1. **Location header uses `#` not `?`.**

MSAL browser v3 sends `response_mode=fragment` and reads the auth code from `window.location.hash`. A `?` redirect puts the code in the query string where MSAL never looks — `handleRedirectPromise()` fires and exits without processing anything.

2. **Token URL pattern must end in `*`.**
MSAL appends `?client-request-id=...` to the token endpoint URL. Without a trailing wildcard (`oauth2/v2.0/token*`) the pattern never matches, EntraMockResponsePlugin skips it, and AuthPlugin returns 401.

3. **Token response must include `Access-Control-Allow-Origin`.**

The token exchange is a `fetch()` with `mode: cors`. Without this header the browser blocks the response even though Dev Proxy returned 200.

4. **Use a fixed nonce, not the `@dynamic.` prefix.**

The `@dynamic.` nonce substitution in id_token payloads is unreliable. Instead, embed `"nonce":"mocked-nonce"` directly in the id_token and pass the same fixed nonce in the `loginRedirect` call (Step 8). `state=@dynamic` in the Location header remains required and does work correctly.

### Pre-computed tokens for the default dummy IDs

If using `TENANT_ID = aaaabbbb-cccc-dddd-eeee-ffffaaaabbbb` and

`CLIENT_ID = 11112222-3333-4444-5555-666677778888`, use the tokens below verbatim.

If using different IDs, run the PowerShell at the end of this step to regenerate them.

```json

{

"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.mocksfile.schema.json",

"mocks": [

{

"request": {

"url": "https://login.microsoftonline.com/*/oauth2/v2.0/authorize*",

"method": "GET"

},

"response": {

"statusCode": 302,

"headers": [

{

"name": "Location",

"value": "APP_URL/#code=MOCK_AUTH_CODE&state=@dynamic&session_state=MOCK_SESSION"

}

],

"body": ""

}

},

{

"request": {

"url": "https://login.microsoftonline.com/*/oauth2/v2.0/token*",

"method": "POST"

},

"response": {

"statusCode": 200,

"headers": [

{ "name": "Content-Type", "value": "application/json; charset=utf-8" },

{ "name": "Access-Control-Allow-Origin", "value": "APP_URL" }

],

"body": {

"token_type": "Bearer",

"scope": "api://CLIENT_ID/user_impersonation",

"expires_in": 3599,

"access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ2ZXIiOiIyLjAiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vYWFhYWJiYmItY2NjYy1kZGRkLWVlZWUtZmZmZmFhYWFiYmJiL3YyLjAiLCJzdWIiOiJBQUFBQUFBQUFBQUFBQUFBQUFBQUFKUjBvSUIzR1BRRTFPYzBHaHlKOUEiLCJhdWQiOiJhcGk6Ly8xMTExMjIyMi0zMzMzLTQ0NDQtNTU1NS02NjY2Nzc3Nzg4ODgiLCJzY3AiOiJ1c2VyX2ltcGVyc29uYXRpb24iLCJhcHBpZCI6IjExMTEyMjIyLTMzMzMtNDQ0NC01NTU1LTY2NjY3Nzc3ODg4OCIsImF6cCI6IjExMTEyMjIyLTMzMzMtNDQ0NC01NTU1LTY2NjY3Nzc3ODg4OCIsImV4cCI6OTk5OTk5OTk5OSwiaWF0IjoxNzAwMDAwMDAwLCJuYmYiOjE3MDAwMDAwMDAsIm9pZCI6ImFhYWFiYmJiLWNjY2MtZGRkZC1lZWVlLWZmZmZhYWFhYmJiYiIsInRpZCI6ImFhYWFiYmJiLWNjY2MtZGRkZC1lZWVlLWZmZmZhYWFhYmJiYiIsImFpbyI6Im1vY2tfYWlvIn0.MOCK_SIG",

"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ2ZXIiOiIyLjAiLCJpc3MiOiJodHRwczovL2xvZ2luLm1pY3Jvc29mdG9ubGluZS5jb20vYWFhYWJiYmItY2NjYy1kZGRkLWVlZWUtZmZmZmFhYWFiYmJiL3YyLjAiLCJzdWIiOiJBQUFBQUFBQUFBQUFBQUFBQUFBQUFKUm9JQjNHUFFFMU9jMEdoeUo5QSIsImF1ZCI6IjExMTEyMjIyLTMzMzMtNDQ0NC01NTU1LTY2NjY3Nzc3ODg4OCIsImV4cCI6OTk5OTk5OTk5OSwiaWF0IjoxNzAwMDAwMDAwLCJuYmYiOjE3MDAwMDAwMDAsIm5hbWUiOiJNb2NrIFVzZXIiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJtb2NrdXNlckBleGFtcGxlLmNvbSIsIm9pZCI6ImFhYWFiYmJiLWNjY2MtZGRkZC1lZWVlLWZmZmZhYWFhYmJiYiIsInRpZCI6ImFhYWFiYmJiLWNjY2MtZGRkZC1lZWVlLWZmZmZhYWFhYmJiYiIsIm5vbmNlIjoibW9ja2VkLW5vbmNlIiwiYWlvIjoibW9ja19haW8ifQ.MOCK_SIG"

}

}

}

]

}

```

### Regenerating tokens for different IDs

Run this PowerShell, substituting your actual TENANT_ID and CLIENT_ID, then replace the `access_token` and `id_token` values in the file above:

```powershell

$TENANT_ID = 'YOUR_TENANT_ID'

$CLIENT_ID = 'YOUR_CLIENT_ID'

$accessPayload = "{`"ver`":`"2.0`",`"iss`":`"https://login.microsoftonline.com/$TENANT_ID/v2.0`",`"sub`":`"AAAAAAAAAAAAAAAAAAAAAJRoIB3GPQE1Oc0GhyJ9A`",`"aud`":`"api://$CLIENT_ID`",`"scp`":`"user_impersonation`",`"appid`":`"$CLIENT_ID`",`"azp`":`"$CLIENT_ID`",`"exp`":9999999999,`"iat`":1700000000,`"nbf`":1700000000,`"oid`":`"$TENANT_ID`",`"tid`":`"$TENANT_ID`",`"aio`":`"mock_aio`"}"

$idPayload = "{`"ver`":`"2.0`",`"iss`":`"https://login.microsoftonline.com/$TENANT_ID/v2.0`",`"sub`":`"AAAAAAAAAAAAAAAAAAAAAJRoIB3GPQE1Oc0GhyJ9A`",`"aud`":`"$CLIENT_ID`",`"exp`":9999999999,`"iat`":1700000000,`"nbf`":1700000000,`"name`":`"MockUser`",`"preferred_username`":`"mockuser@example.com`",`"oid`":`"$TENANT_ID`",`"tid`":`"$TENANT_ID`",`"nonce`":`"mocked-nonce`",`"aio`":`"mock_aio`"}"

function ConvertTo-Base64Url($json) {

$bytes = [System.Text.Encoding]::UTF8.GetBytes($json)

[System.Convert]::ToBase64String($bytes).Replace('+','-').Replace('/','_').TrimEnd('=')

}

$header = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9"

Write-Output "access_token: $header.$(ConvertTo-Base64Url $accessPayload).MOCK_SIG"

Write-Output "id_token: $header.$(ConvertTo-Base64Url $idPayload).MOCK_SIG"

```

---

## Step 5 — Write api-mocks.json

Write this empty template to the web app root:

```json

{

"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v3.0.0/mockresponseplugin.mocksfile.schema.json",

"mocks": []

}

```

---

## Step 6 — Write src/authConfig.ts

Write this file to the web app `src/` directory, substituting TENANT_ID, CLIENT_ID, and APP_URL.

If the file already exists with different IDs, preserve the existing IDs.

```typescript

import { Configuration, LogLevel } from '@azure/msal-browser';

const TENANT_ID = 'TENANT_ID';

const CLIENT_ID = 'CLIENT_ID';

export const msalConfig: Configuration = {

auth: {

clientId: CLIENT_ID,

authority: `https://login.microsoftonline.com/${TENANT_ID}`,

redirectUri: 'APP_URL',

postLogoutRedirectUri: 'APP_URL',

},

system: {

loggerOptions: {

loggerCallback: (_level, message) => console.log('[MSAL]', message),

logLevel: LogLevel.Warning,

},

},

};

export const loginRequest = {

scopes: [`api://${CLIENT_ID}/user_impersonation`],

};

```

---

## Step 7 — Update the application entry point (main.tsx / index.tsx)

Read the existing entry point. Apply these changes:

1. Import `PublicClientApplication` from `@azure/msal-browser`, `MsalProvider` from `@azure/msal-react`, and `msalConfig` from `./authConfig`.

2. Create the MSAL instance **outside** React's render cycle (module scope).

3. Move `createRoot(...).render(...)` **inside** `msalInstance.initialize().then(...)`.

Without this, `loginRedirect()` throws `uninitializedPublicClientApplication` silently before the try/catch in the sign-in handler can catch it — the button appears to do nothing.

4. Wrap the root component in `<MsalProvider instance={msalInstance}>`.

```tsx

import { StrictMode } from 'react';

import { createRoot } from 'react-dom/client';

import { PublicClientApplication } from '@azure/msal-browser';

import { MsalProvider } from '@azure/msal-react';

import { msalConfig } from './authConfig';

import App from './App';

const msalInstance = new PublicClientApplication(msalConfig);

msalInstance.addEventCallback(event => {

if (event.error) console.error('[MSAL]', event.eventType, event.error);

else console.log('[MSAL event]', event.eventType, event.payload ?? '');

});

msalInstance.initialize().then(() => {

createRoot(document.getElementById('root')!).render(

<StrictMode>

<MsalProvider instance={msalInstance}>

<App />

</MsalProvider>

</StrictMode>

);

});

```

---

## Step 8 — Wire the fixed nonce into the login call

Find the component that calls `instance.loginRedirect()`. Add `nonce: 'mocked-nonce'` to the request object. This must match the `"nonce":"mocked-nonce"` claim embedded in the id_token in entra-mocks.json. Without it, MSAL generates a random nonce, stores it in sessionStorage, and then rejects the returned id_token because the nonces don't match — the auth flow silently fails after the redirect.

```tsx

await instance.loginRedirect({ ...loginRequest, nonce: 'mocked-nonce' });

```

Do **not** add `nonce` to `loginRequest` itself. `acquireTokenSilent` spreads `loginRequest`

too, and a stale nonce there causes silent refresh to fail.

---

## Step 9 — Write .env.local

Write this to the web app root. The cert file must be exported once per machine with `devproxy certificate get --output devproxy-ca.crt`. Without it, Node/Vite rejects Dev Proxy's TLS interception with `ERR_CERT_AUTHORITY_INVALID`.

```

NODE_EXTRA_CA_CERTS=./devproxy-ca.crt

```

---

## Step 10 — Initialize devproxy with its certificate

```powershell

devproxy certificate get --output devproxy-ca.crt

```

## Step 11 — Give the user run instructions

After writing all files:

```

To start the mock auth flow:

1. Start Dev Proxy (from the web app directory):

devproxy

Accept the CA trust prompt on first run.

2. Start the dev server in a second terminal:

npm run dev

3. Open APP_URL — sign in with the button.

The page briefly redirects and returns; that is the mock auth flow working.

Note: if you ed entra-mocks.json or api-mocks.json then restart Dev Proxy (Ctrl+C, then devproxy)— Dev Proxy does not hot-reload those files.

```

### Start

```powershell

# From the folder containing devproxyrc.json (auto-loaded)

devproxy

# Point at a specific config file

devproxy --config-file ./config/devproxyrc.json

# Don't touch the system proxy (useful in CI or when another proxy is active)

devproxy --as-system-proxy false

```

---

## Troubleshooting

| Symptom | Cause | Fix |

|---|---|---|

| Button click does nothing; console shows `msal:handleRedirectStart` → `msal:handleRedirectEnd` with no token events in between | Location header uses `?` — MSAL looks only at `window.location.hash` | Change `?code=` to `#code=` in the authorize mock Location header |

| `msal:loginFailure 401 Unauthorized`; Dev Proxy shows `AuthPlugin: 401 Authorization header not found` | Token URL mock not matched (query params present, no trailing wildcard) | Ensure token URL pattern ends in `*`: `oauth2/v2.0/token*` |

| CORS error on token POST despite Dev Proxy returning 200 | Token mock response missing `Access-Control-Allow-Origin` | Add `{"name":"Access-Control-Allow-Origin","value":"APP_URL"}` to the token mock response headers |

| `msal:loginFailure` nonce mismatch | Random nonce stored by MSAL doesn't match static nonce in id_token | Pass `nonce: 'mocked-nonce'` in the `loginRedirect` call; ensure id_token payload contains `"nonce":"mocked-nonce"` |

| Sign-in button does nothing, no MSAL events in console | `render()` called before `initialize()` completes | Move render inside `msalInstance.initialize().then(...)` |

| Mock changes not picked up | Dev Proxy reads config files at startup only | Restart Dev Proxy after editing any mock file |

| `ERR_CERT_AUTHORITY_INVALID` in browser | Dev Proxy CA not trusted | Accept the cert prompt on startup, or run `devproxy certificate install` |

| `ERR_CERT_AUTHORITY_INVALID` in Vite/Node | Node ignores the Windows certificate store | Set `NODE_EXTRA_CA_CERTS=./devproxy-ca.crt` in `.env.local` |

## Support starting and stopping Dev Proxy from the CLI

### Start

```powershell

# From the folder containing devproxyrc.json (auto-loaded)

devproxy

# Point at a specific config file

devproxy --config-file ./config/devproxyrc.json

# Don't touch the system proxy (useful in CI or when another proxy is active)

devproxy --as-system-proxy false

```

Don't display the start instructions again if the user has already run the command once in this terminal session.

### Stop

From the running terminal: **Ctrl+C**

From a second terminal:

```powershell

devproxy stop # Stop all instances

devproxy stop --pid 12345 # Stop a specific instance

devproxy stop --force # Force-terminate if graceful stop fails

```

Don't display the start instructions again if the user has already run the command once in this terminal session.

 

As a bonus, here are four failures encountered in this process and how we fixed them:

BONUS: DEV PROXY FIXES

Four failures. Four fixes.

These surfaced while testing the command with Microsoft Dev Proxy. All four are built into the command, so you don’t have to rediscover them.

01

Use #, not ?, in the Location header

SYMPTOM

The sign-in button appears to do nothing.

WHY

MSAL reads the auth code from the URL hash. A ? puts the code in the query string, where MSAL never looks.

USE THIS

#code=MOCK_AUTH_CODE

02

End the token URL pattern with *

SYMPTOM

Login fails with 401 Unauthorized.

WHY

MSAL adds a query string to the token endpoint URL. Without a trailing wildcard, the mock never matches.

USE THIS

oauth2/v2.0/token*

03

Add a CORS header to the token response

SYMPTOM

A CORS error on the token request, even though Dev Proxy returned 200.

WHY

The token exchange is a cross-origin fetch, so the browser blocks a response that lacks the header.

USE THIS

Access-Control-Allow-Origin: APP_URL

04

Use a fixed nonce, not @dynamic

SYMPTOM

Login fails with a nonce mismatch.

WHY

Dynamic nonce substitution is unreliable inside the id_token. Put a fixed nonce in the token and pass the same value in the login call.

USE THIS

nonce: 'mocked-nonce'

✓ SKILL.md already includes all four.

Learning Tree International can offer Anthropic’s certification portfolio as a member of the Claude Partner Network.

Claude Partner Badge

 

THE COMPLETE COMMAND

The Claude Command’s SKILL.md file

289 lines. Save it in your project as .claude/skills/dev-proxy/SKILL.md

Show the full file and copy it

Click inside the box, press Ctrl+A (⌘+A on a Mac) to select the whole file, then copy.

Frequently Asked Questions (FAQs)

What is the difference between a Claude Code skill and a command?

Both are implemented with a SKILL.md file. A skill is selected automatically by Claude when a request matches its description, while a command is run explicitly from the Claude Code CLI with a forward slash and the command name.

Why create a command instead of reusing the same prompt?

A command captures repeatable instructions in one maintained file. When you improve that file, the fix becomes available to every project that uses the command instead of solving the same problem separately in each application.

What can the Dev Proxy and MSAL command automate?

The example command can check or install Microsoft Dev Proxy, create the required proxy and mock configuration files, install and wire MSAL packages into a React and TypeScript application, and provide instructions for starting and stopping Dev Proxy.

How should a Claude Code command be debugged?

Run the command against a real application, ask Claude Code to explain failures, back out test changes, and apply the discovered fix to the command itself. Repeat that loop until the command works reliably.