Skip to content
AI & Agents
Hook

Hooks

What copilot-studio runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.

From plugin
copilot-studio
49631 skills4 agents1 hook

Claude Code

> /plugin marketplace add microsoft/skills-for-copilot-studio
> /plugin install copilot-studio@skills-for-copilot-studio

What fires, and when

SessionStart

Fires once when a session begins, and again after a context compaction. It is where a plugin sets up its environment, or restores state the compaction dropped.

  • node -e "var r=process.env.CLAUDE_PLUGIN_ROOT;if(r){var f=require('fs'),p=require('path');var t=f.readFileSync(p.join(r,'hooks','system-prompt.md'),'utf8');process.stdout.write(JSON.stringify({hookSpecificOutput:{hookEventName:'SessionStart',additionalContext:t}}))}"node -e "var r=process.env.CLAUDE_PLUGIN_ROOT;if(r){var p=require('path');require(p.join(r,'hooks','setup.js'))}"
Read hooks/hooks.json

Where it lives

  • hooks/print-prompt.jsGitHub
    Read the script
    const path = require('path');
    const fs = require('fs');
    
    const text = fs.readFileSync(path.join(__dirname, 'system-prompt.md'), 'utf8');
    
    // Copilot CLI (v1.0.11+) injects additionalContext from JSON output.
    // Claude Code captures raw stdout as context.
    // Detect runtime and output the appropriate format.
    if (process.env.COPILOT_CLI) {
      process.stdout.write(JSON.stringify({ additionalContext: text }));
    } else {
      process.stdout.write(text);
    }
    
  • hooks/setup-env.jsGitHub
    Read the script
    const fs = require('fs');
    const path = require('path');
    
    function shellQuote(value) {
      if (typeof value !== 'string' || value.includes('\0')) {
        throw new Error('Plugin paths must be strings without NUL characters.');
      }
      return "'" + value.replace(/'/g, "'\\''") + "'";
    }
    
    function persistEnvironment(envFile, pluginData, pluginRoot) {
      if (!path.isAbsolute(envFile) || envFile.includes('\0')) {
        throw new Error('CLAUDE_ENV_FILE must be an absolute file path.');
      }
      const content = '\nexport CLAUDE_PLUGIN_DATA=' + shellQuote(pluginData) +
        '\nexport CLAUDE_PLUGIN_ROOT=' + shellQuote(pluginRoot) + '\n';
      const existing = fs.lstatSync(envFile, { throwIfNoEntry: false });
      if (existing && !existing.isFile()) {
        throw new Error('CLAUDE_ENV_FILE must be a regular file, not a symlink.');
      }
      const flags = fs.constants.O_WRONLY | fs.constants.O_APPEND |
        fs.constants.O_CREAT | fs.constants.O_NONBLOCK | fs.constants.O_NOFOLLOW;
      const fd = fs.openSync(envFile, flags, 0o600);
      try {
        const opened = fs.fstatSync(fd);
        const entry = fs.lstatSync(envFile);
        if (!opened.isFile() || entry.isSymbolicLink() ||
            opened.dev !== entry.dev || opened.ino !== entry.ino) {
          throw new Error('CLAUDE_ENV_FILE must be a regular file, not a symlink.');
        }
        fs.writeFileSync(fd, content);
      } finally {
        fs.closeSync(fd);
      }
    }
    
    module.exports = { shellQuote, persistEnvironment };
    
  • hooks/setup.jsGitHub
    Read the script
    const fs = require('fs');
    const cp = require('child_process');
    const p = require('path');
    const os = require('os');
    const { persistEnvironment } = require('./setup-env');
    
    // __dirname is the hooks/ directory; the plugin root is one level up
    const r = p.resolve(__dirname, '..');
    const d = process.env.CLAUDE_PLUGIN_DATA || process.env.COPILOT_PLUGIN_DATA;
    const e = process.env.CLAUDE_ENV_FILE;
    
    if (!r || !d) {
      process.exit(0);
    }
    
    const src = p.join(r, 'scripts', 'native-deps.json');
    const dst = p.join(d, 'package.json');
    
    try {
      if (fs.readFileSync(src, 'utf8') !== fs.readFileSync(dst, 'utf8')) throw 0;
    } catch {
      fs.mkdirSync(d, { recursive: true });
      fs.copyFileSync(src, dst);
      cp.execSync('npm install --no-audit --no-fund', { cwd: d, stdio: 'inherit' });
    }
    
    var pd = p.join(os.homedir(), '.copilot-studio-cli');
    fs.mkdirSync(pd, { recursive: true });
    fs.writeFileSync(
      p.join(pd, 'plugin-paths.json'),
      JSON.stringify({ pluginData: d, pluginRoot: r })
    );
    
    if (e) {
      persistEnvironment(e, d, r);
    }
    

Read the script before you install anything that runs on your machine. This is the one part of a plugin that acts without being asked.

@microsoft
Ships withcopilot-studio

A plugin for Claude Code, GitHub Copilot CLI, and VS Code that enables authoring, testing, and troubleshooting Microsoft Copilot Studio STANDARD agents through YAML files — directly from your terminal or editor.

49631 skills4 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
496
Star history of microsoft/skills-for-copilot-studio on GitHub, a chart by star-history.com

More plugins that ship hooks.

qiushi-skill

qiushi-skill

Helps Claude Code weigh evidence before judging, review its own finished work, and focus on one main task at a time when several compete. Each method comes from classic dialectical and practical philosophy.

11 skills+33.9k
@hughyau@hughyau
Install Plugin
allium

allium

Gives Claude Code agents a structured specification language called Allium. Skills let you write, distil from existing code, elicit requirements into, and generate tests from Allium specs.

7 skills+2540
@juxt@juxt
Install Plugin
taskmaster

taskmaster

Taskmaster is a completion guard for coding agents. It addresses a common failure mode: the agent makes partial progress, writes a summary, and stops before the user goal is actually finished.

1 skill2 hooks535
@blader@blader
Install Plugin
codex-skill

codex-skill

Give Claude Code a "second opinion" by letting it consult OpenAI's Codex CLI for independent verification.

1 skill1 hook230
@cathrynlavery@cathrynlavery
Install Plugin
harness

harness

A practical configuration kit for Claude Code, Codex, and other coding agents. It contains architectural principles, enforcement hooks, skills, drop-in rules, starter templates, and dynamic-workflow commands.

60 skills+2215
@anastasiyaw@anastasiyaw
Install Plugin
uipath

uipath

UiPath Agent Skills give AI coding agents the domain knowledge to build, run, test, and deploy UiPath automations and agents, directly from your development environment.

32 skills+2184
@uipath@uipath
Install Plugin

Questions about the hooks in copilot-studio.

Which coding agents can use the hooks in copilot-studio?
The hooks in copilot-studio install in Claude Code and Cursor: each runs Claude Code hooks from .claude/settings.json, so copy the hooks there.