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
46931 skills4 agents1 hook
Install
> /plugin marketplace add microsoft/skills-for-copilot-studio
> /plugin install copilot-studio@skills-for-copilot-studio

Ships with copilot-studio. Installing the plugin gets these hooks.

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.jsGitHub
    Read the script
    const fs = require('fs');
    const cp = require('child_process');
    const p = require('path');
    const os = require('os');
    
    // __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) {
      fs.appendFileSync(
        e,
        'export CLAUDE_PLUGIN_DATA="' + d + '"\nexport CLAUDE_PLUGIN_ROOT="' + r + '"\n'
      );
    }
    

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.

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.

Get the whole plugin
Stats
469
Stars
101
Forks
Active
Maintenance
JavaScript
Language
MIT
License
14h ago
Last commit
9mo ago
Created
5h ago
Added

Repo: microsoft/skills-for-copilot-studio