teams-sdk
Copilot instructions728 starsChanged 7 months agoMITView on GitHub
This is a TypeScript CLI tool (teams) for managing Microsoft Teams apps. It uses Commander.js for command parsing, MSAL for auth, and talks to TDP (Teams Developer Portal) APIs. Be extremely concise — sacrifice grammar for brevity. Every comment MUST include an importance level prefix: Use logger from src/utils/logger.ts for all output. Never use console.log/console.error directly (except inside logger.ts and json-output.ts). For error conditions, throw CliError from src/utils/errors.ts. Wrap command .action() handlers with wrapAction() — it catches CliError and unknown…
In this repository3 other files it gives its agents.
- packages/cli/AGENTS.mdAGENTS.md
- teams.md/static/llms_docs/llms.txtllms.txt
- teams-devSkill
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
15 rules. About 0 are common, 3 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 18
Avoid as unknown as X double-casts and any types.
- Very specific: line 19
Use Intl.DateTimeFormat via formatDate() from src/utils/date.ts for dates — no moment or date-fns.
- Very specific: line 20
Use picocolors (pc) for terminal styling:
- Very specific: line 29
Use logger from src/utils/logger.ts for all output.
- Very specific: line 40
Use createSilentSpinner() from src/utils/spinner.ts (not createSpinner from nanospinner directly).
- Very specific: line 45
Do NOT mark as [OPTIONAL] if the value will be prompted interactively when not provided.
- Very specific: line 53
Every command MUST support --json (boolean flag, marked [OPTIONAL]).
- Distinctive: line 57
Use Commander's built-in features for global flags and hooks.
- Very specific: line 58
Don't manually parse process.argv — use .option() on the program and access via optsWithGlobals() in preAction hooks.
- Distinctive: line 62
Check if a shared function already exists before implementing logic.
- Distinctive: line 64
Never duplicate business logic across interactive menus and CLI subcommands — both should call the same shared function.
- Very specific: line 68
Always run npm run build after changes — the CLI runs from dist/, not source.
- Very specific: line 74
Create AAD apps via TDP's /aadapp/v2 endpoint (createAadAppViaTdp in src/apps/tdp.ts), NOT via Graph API directly.
- Very specific: line 91
Always output CLIENT_ID, CLIENT_SECRET, and TENANT_ID together.
- Very specific: line 96
Default location is Teams-managed, overridable via --azure/--teams-managed flags or teams config set default-bot-location.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions
This is a TypeScript CLI tool (teams) for managing Microsoft Teams apps. It uses Commander.js for command parsing, MSAL for auth, and talks to TDP (Teams Developer Portal) APIs.
Review Style
Be extremely concise — sacrifice grammar for brevity. Every comment MUST include an importance level prefix:
- [CRITICAL] — Bugs, security issues, data loss. Must fix.
- [HIGH] — Correctness, perf, or maintainability problems. Should fix.
- [NIT] — Style, naming, minor cleanup. Optional.
Code Style
TypeScript
- Strong, precise types are extremely important. Every interface, output shape, and function signature must be explicitly typed — never fall back to
Record<string, unknown>,any, or untyped parameters when a concrete type is possible. Define dedicated interfaces for command options, JSON output shapes, and API responses. - Avoid
as unknown as Xdouble-casts andanytypes. Prefer fixing the underlying type (adding a field to an interface, using a proper generic, etc.) over casting. - Use
Intl.DateTimeFormatviaformatDate()fromsrc/utils/date.tsfor dates — nomomentordate-fns. - Use
picocolors(pc) for terminal styling:- Success/username:
pc.bold(pc.green(...)) - Warning:
pc.yellow(...) - Command hints:
pc.cyan(...) - Labels:
pc.dim(...) - Errors:
pc.red(...)
- Success/username:
Logging & Errors
Use logger from src/utils/logger.ts for all output. Never use console.log/console.error directly (except inside logger.ts and json-output.ts).
logger.info(...)— general output (stdout)logger.warn(...)— warnings (stderr)logger.error(...)— errors (stderr)logger.debug(...)— verbose-only, gated by--verbose
For error conditions, throw CliError from src/utils/errors.ts. Wrap command .action() handlers with wrapAction() — it catches CliError and unknown errors, routes to JSON or human output, and handles ExitPromptError gracefully.
Spinners
Use createSilentSpinner() from src/utils/spinner.ts (not createSpinner from nanospinner directly). Pass silent = true when --json is active to suppress visual output. Always include descriptive text.
CLI Options
- Prefix truly optional flags with
[OPTIONAL]in their description. - Do NOT mark as
[OPTIONAL]if the value will be prompted interactively when not provided.
Auto-Confirm (--yes / -y)
The --yes global flag skips interactive confirmation prompts (for CI/agent use). State is managed via setAutoConfirm/isAutoConfirm in src/utils/interactive.ts. Before any confirm() call, check isAutoConfirm() and accept the default action if true.
JSON Output
Every command MUST support --json (boolean flag, marked [OPTIONAL]). Each command defines a typed output interface in its own file (e.g., AppCreateOutput). Use outputJson() from src/utils/json-output.ts. Guard all human output (logger.info, outputCredentials) with if (!options.json). Skip interactive prompts in JSON mode — use defaults or require flags.
Commander Patterns
- Use Commander's built-in features for global flags and hooks.
- Don't manually parse
process.argv— use.option()on the program and access viaoptsWithGlobals()inpreActionhooks.
Code Reuse
- Check if a shared function already exists before implementing logic.
- Extract reusable logic into shared modules (
src/utils/, action files likemanifest/actions.ts,secret/generate.ts). - Never duplicate business logic across interactive menus and CLI subcommands — both should call the same shared function.
Build
Always run npm run build after changes — the CLI runs from dist/, not source. tsc --noEmit only type-checks. From the monorepo root, use npx turbo build --filter=@microsoft/teams.cli.
Architecture
AAD App Creation — Use TDP, Not Graph API
Create AAD apps via TDP's /aadapp/v2 endpoint (createAadAppViaTdp in src/apps/tdp.ts), NOT via Graph API directly. TDP's backend creates the service principal server-side, which is required for single-tenant bot registration.
signInAudience: AlwaysAzureADMultipleOrgs(multi-tenant AAD app)isSingleTenant: Alwaystrueon bot registration (SFI requirement)- TDP returns a different
idthan Graph's object ID — usegetAadAppByClientIdto look up the Graph object ID before callingaddPassword - Graph replication lag may require retries after TDP creates the app
Tenant Cross-Validation
Any command that uses both MSAL (Teams login) and Azure CLI must call ensureTenantMatch(account.tenantId) from src/utils/az-prompts.ts before creating Azure resources. This throws CliError("TENANT_MISMATCH", ...) if account.tenantId (MSAL) differs from the Azure CLI's active tenant (az account show). The status command displays the match/mismatch but does not throw.
Auth Client ID
Uses shared public client 7ea7c24c-b1f6-4a20-9d11-9ae12e9e7ac0. TDP's own web UI uses a different first-party client ID (e1979c22) which we cannot use for CLI auth.
Credential Output
Always output CLIENT_ID, CLIENT_SECRET, and TENANT_ID together. The TENANT_ID comes from account.tenantId (MSAL AccountInfo).
Bot Location
- Detection uses
getBotLocation(token, botId)insrc/apps/bot-location.ts— calls/botframework/{botId}, 200 = "tm" (Teams-managed), 404 = "azure". - Default location is Teams-managed, overridable via
--azure/--teams-managedflags orteams config set default-bot-location. - SSO URI must be
api://botid-{botId}— Teams regex requiresbotid-prefix.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

