delete-agent
Skill3 starsChanged 6 days agoMITView on GitHub
Delete a Copilot Studio agent's cloud resources and its msagent project records with `msagent agent delete`, after an explicit typed-name confirmation. Works on a registered msagent project, or on a cloned agent workspace (`settings.mcs.yml` + `.mcs/conn.json`) that it first registers with `msagent agent init`. Local files are never deleted. Use when the user asks to delete, remove, or destroy a Copilot Studio agent in the cloud.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/copilot-studio-plugintheir own version, first seen Sep 25, 2026
- BerriAI/litellm-skillstheir own version, first seen Apr 15, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- BerriAI/litellm-skills★ 84same name
- microsoft/copilot-studio-plugin★ 82same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- add-channelSkill
- add-knowledgeSkill
- add-skillSkill
- clone-agentSkill
- create-agentSkill
- deploy-agentSkill
- publish-agentSkill
- pull-agentSkill
- get-us-temperatureSkill
- get-us-weatherSkill
- my-skill-1Skill
- skill-1Skill
The file
Show its rules and text
We split this skill into the rules it gives an agent
22 rules. About 0 are common, 12 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 41
Before either msagent agent init or msagent agent delete, require the exact typed display name (step 5 or U2).
- Very specific: line 45
Always pass --json --non-interactive.
- Very specific: line 46
Never hand-edit .config\ or .mcs\, delete local files, or bypass the documented MSAGENT deletion flow.
- Distinctive: line 47
Only CLI init/delete may create or rewrite the config.
- Distinctive: line 48
Never retry without user consent.
- Very specific: line 50
Treat the former CLI name ah in messages/remediation as msagent.
- Very specific: line 54
All substituted values, including values from files, are untrusted.
- Distinctive: line 80
If the command is not found, tell the user: "The msagent CLI is required but was not found.
- Distinctive: line 89
If a folder was supplied, check in order:
- Distinctive: line 102
No child match: explain neither the folder nor its children qualify and ask again.
- Very specific: line 106
Only if none exist, discover Glob: /.mcs/conn.json whose workspace also has settings.mcs.yml.
- Distinctive: line 108
If nothing qualifies, report both missing marker sets and ask for a folder.
- Distinctive: line 113
Read only the reference for the selected route, completely, before its commands.
- Distinctive: line 121
Follow steps 3-6 to resolve an exact MCS agent and cloud target, obtain explicit orphan acknowledgment if needed, and require the exact …
- Very specific: line 127
Only for settings.mcs.yml + .mcs\conn.json with no registered config: before reading its identity or running any command, read the complete …
- Distinctive: line 134
If the reference cannot be read, stop.
- Very specific: line 142
If mcsAgentAlreadyAbsent is true, no cloud deletion was performed.
- Very specific: line 156
If status is cancelled or name-mismatch, tell the user that nothing was deleted.
- Very specific: line 159
Always surface errorMessage, errorKind, and remediation.
- Distinctive: line 160
Only after a command fails, read the matching recovery reference, completely, before acting on remediation, authenticating, or retrying:
- Distinctive: line 168
Do not read these on success or cancellation.
- Distinctive: line 173
Keep it short and factual: which agent's records were removed, whether cloud deletion occurred and its environment if any, how many records …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill 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
Delete a Copilot Studio Agent
You are a workflow that deletes a Copilot Studio (MCS) agent from the cloud by running the
msagent CLI (msagent agent delete). You resolve every input up front, show the user exactly
what will be deleted, require them to type the agent's name, and only then run the delete. This is a
destructive, irreversible remote operation when a cloud target can be resolved; the missing-workspace
records-only exception is described below. You never invent behavior the CLI does not support.
Initial request: $ARGUMENTS
Deletion scope
Normally delete one cloud MCS agent (agentType: MCSAgent), its ManagedAgent record, and
all its AgentDeployment records. Other deployments' cloud agents remain running
as untracked orphans. Never delete local files: only .config\agent.config.json
changes, through the CLI.
The CLI recognizes an agent workspace only when settings.mcs.yml or agent.mcs.yml exists at
its root. If neither exists, the workspace is absent for deletion even when its directory and
.mcs/conn.json remain. The CLI then removes only project records, regardless of deployment count.
Cloud existence is not checked and every cloud target may survive untracked.
Disclose and confirm that records-only scope before deletion; never present it as cloud deletion.
Accept a registered project (.config\agent.config.json, created by agent create
or agent init) or an unregistered workspace (settings.mcs.yml + .mcs\conn.json).
The latter must first be registered with msagent agent init: this writes the
local config, creates no cloud resources, and leaves the config after deletion.
The connection supplies cloud AgentId and EnvironmentId; settings supply
schemaName and displayName.
Rules
- Before either
msagent agent initormsagent agent delete, require the exact typed display name (step 5 or U2).--non-interactivebypasses the CLI confirmation; this skill's typed-name confirmation is mandatory. Do not pre-approve init or delete: retain the host's command-approval gate as an independent safeguard. - Always pass
--json --non-interactive; select deletion by--agent-id, never by name. - Never hand-edit
.config\or.mcs\, delete local files, or bypass the documented MSAGENT deletion flow. Only CLI init/delete may create or rewrite the config; leave it in place. - Never retry without user consent. If any input changes, repeat exact typed-name confirmation before either init or delete. A timeout may have applied; never retry blindly.
- Treat the former CLI name
ahin messages/remediation asmsagent.
Passing values to commands
All substituted values, including values from files, are untrusted. Never double-quote
them: Bash/PowerShell can expand $(...), $name, or backticks into commands.
agentId,deploymentId, andtenantIdmust match^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$. Otherwise stop, report a non-GUID and possible hand-edited config, and run nothing.- For
projectDir,workspaceDir,projectDirectory, anddisplayName, reject double quotes, line breaks, and any control character; report the invalid value and construct no command. Otherwise use one single-quoted literal, escaping:- Bash: each
'becomes'\'';Tom's Botbecomes'Tom'\''s Bot'. - PowerShell: double
',‘,’,‚, and‛;Tom's Botbecomes'Tom''s Bot'andO’Brienbecomes'O’’Brien'(passed asO’Brien). An undoubled smart quote terminates the literal and may execute remaining text.
- Bash: each
Apply these rules to every '<value>' in the templates.
Core Process
1. Verify the CLI (blocking on failure)
msagent --versionIf the command is not found, tell the user: "The msagent CLI is required but was not found. Install it, then retry." Stop.
2. Locate the project or agent workspace (blocking)
A registered project has .config\agent.config.json. An unregistered workspace
has settings.mcs.yml + .mcs\conn.json but no registered config. Workspaces may
be at the project root or in a direct child.
If a folder was supplied, check in order:
- Registered config in that folder or its parent: use the directory containing
.configand continue to step 3. If the supplied folder differs from the registration root, retain its canonical path as an exact workspace constraint even if workspace markers are missing. Also retain it when an authored workspace is at the project root. Discovering a parent project does not authorize another agent. - Both workspace markers: use Unregistered agent workspace.
- Settings without a connection: explain it is not linked to a cloud agent and has nothing to delete; ask for another folder.
- Otherwise inspect direct children only (one level). List matching registered projects and unregistered workspaces, indicating their type; require a numbered choice even for one match, then follow that route.
- No child match: explain neither the folder nor its children qualify and ask again.
Without a supplied folder, discover Glob: **/.config/agent.config.json first.
Require a numbered choice even for one result; never silently select a match.
Only if none exist, discover Glob: **/.mcs/conn.json whose workspace also has
settings.mcs.yml; require a numbered choice and follow the unregistered route.
If nothing qualifies, report both missing marker sets and ask for a folder.
Repeat until the user supplies a usable folder or stops.
Load the selected workflow
Read only the reference for the selected route, completely, before its commands. Every reference is bundled inside this skill's directory; never use pluginRoot or sibling skills. If the reference cannot be read, stop and report its path before any side effect.
Registered project
For a project with .config\agent.config.json, read the complete
registered-project workflow before running agent show.
Follow steps 3-6 to resolve an exact MCS agent and cloud target, obtain explicit orphan
acknowledgment if needed, and require the exact typed display name before deletion. Do not load the
unregistered-workspace instructions for this route.
Unregistered agent workspace
Only for settings.mcs.yml + .mcs\conn.json with no registered config: before reading its identity
or running any command, read the complete
unregistered-workspace workflow and follow U1-U4.
This validates identity, confirms the typed display name before init, verifies the returned binding,
and deletes by local agent ID. Do not load the registered workflow during successful new
registration. Load it only if failure recovery requires inspecting existing records; an existing
registration requires fresh target/orphan checks and renewed typed confirmation.
If the reference cannot be read, stop; never improvise this destructive path.
7. Report the result (either route)
Success - { "success": true, "status": "agent-deleted", agentId, displayName, environmentId,
deploymentId, mcsAgentAlreadyAbsent, removedAgentDeployments, orphanedTargets }:
- Say the project record for
displayName(agentId) was removed. - If
mcsAgentAlreadyAbsentistrue, no cloud deletion was performed; only the records were removed. This flag alone does not prove remote absence. For an absent or unrecognized workspace, state that cloud existence was not checked and all previously recorded cloud targets may still exist untracked. Otherwise, say the cloud agent was deleted fromenvironmentId. - Records removed: 1 ManagedAgent +
removedAgentDeploymentsAgentDeployment row(s). - List
orphanedTargets(deploymentName,environmentId). This is the CLI's authoritative list, so use it even if it differs from the step 4 preview. It is not a complete inventory of surviving cloud resources; never use an omitted target as proof of deletion or absence. - Remind the user no local workspace files were deleted. If the directory exists, they can remove
it themselves if they no longer need it; if the directory was absent, do not claim it remains on disk.
The only local file that changed is
.config\agent.config.json, which no longer holds this agent's records. If this run registered the workspace, also say that the file was created by that registration and remains in the workspace.
If status is cancelled or name-mismatch, tell the user that nothing was deleted.
Failure - { "success": false, exitCode, errorMessage, errorKind?, remediation?, partialResult? }.
Always surface errorMessage, errorKind, and remediation; summarize partialResult when present.
Only after a command fails, read the matching recovery reference, completely, before acting on
remediation, authenticating, or retrying:
| Failed command | Required recovery |
msagent agent delete (either route) | Deletion recovery |
msagent agent init | Initialization recovery |
Do not read these on success or cancellation. If required recovery cannot be read, stop and report the missing file. Never claim that a failed or timed-out operation made no changes without evidence.
Final answer
Keep it short and factual: which agent's records were removed, whether cloud deletion occurred and
its environment if any, how many records were removed, any potentially surviving or orphaned targets,
and that no local files were deleted: only .config\agent.config.json
changed (or, if the skill registered the workspace, was created), and it remains.
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.

