CertSafari
    Anthropic Claude Certified Developer – Foundations (CCDV-F)· Lessons

    Domain 2 · Lesson 8/25

    Session hygiene and plugin management in Claude Code

    Claude Application Design

    10 min read
    5.52% of exam
    9 sources
    Published 12 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Choose between /compact with a focus, /clear and subagent delegation for a drifting or bloated session
    • Predict what survives compaction and what is lost
    • Explain what a Claude Code plugin bundles, what it costs in context and trust, which scopes it installs at, and how the Agent SDK loads one

    1.Compact, clear or delegate: the session hygiene rule

    Long Claude Code sessions get worse in a predictable way. Old conversation pushes out the files you need next, and you pay for it in tokens on every message. Session hygiene means choosing one of three moves at each turning point in the work. [Compaction](lesson:6.1) replaces the conversation with a structured summary. [Context isolation with subagents](lesson:6.1) gives a piece of work its own context window. /clear starts the conversation over.

    The choice depends on whether the next piece of work is related to the last. If you are continuing the same task with a bloated context, run /compact with a focus, such as /compact focus on the auth bug fix, before a long new phase. The summary then keeps what you named, instead of what the automatic pass guesses is important. If the next task is unrelated, use /clear. If what comes next is a lot of reading, such as research across a large codebase, send it to a subagent. The file contents stay in the subagent's window, and only a summary and a small metadata trailer come back. If only part of the conversation is noise, /rewind lets you summarize from a chosen message onward, or up to it.

    Choosing a session-hygiene move
    MoveUse it whenWhat the session keeps
    /compact focus on …The same task continues but context is bloatedA structured summary steered by your focus
    /clearYou are switching to unrelated workA fresh conversation; nothing from the old one
    Delegate to a subagentLarge reads or research are nextOnly the summary and a small metadata trailer
    /rewind → Summarize from here / up to hereOnly part of the conversation is noiseThat part summarized, the rest intact

    Most startup content comes back after compaction, so check which parts do not before you rely on it. The system prompt and output style still apply. Project-root CLAUDE.md, unscoped rules and auto memory are re-injected from disk, as is the plan from plan mode. Path-scoped rules and nested CLAUDE.md files return when Claude next reads a matching file. Claude Code re-reads up to five of the files Claude read or edited, most recently modified first, and invoked skill bodies return within a token cap. Anything else, including a standing instruction you typed into chat an hour ago, survives only if the summary keeps it. If an instruction has to outlast compaction, put it in CLAUDE.md. Resuming an old session raises the same choice. Resume from summary runs /compact immediately, while Resume full session as-is reprocesses the whole history.

    Checkpoint 1 of 5· Check yourself

    Two hours ago you told Claude in chat, "never touch the migrations folder". The same rule is also in the project-root CLAUDE.md. After /compact, which copy is guaranteed to be back in context?

    Checkpoint 2 of 5· Exam question

    A multi-tenant SaaS product runs one Agent SDK session per end-user conversation and must reliably return to a specific user's conversation later, even when it isn't the most recently active session on the server and even after the process restarts. Which session-handling approach fits this requirement?

    Applications built on the Agent SDK manage sessions through options rather than a picker. Each result message carries a session_id; capture it per user or per job and pass it as resume to return to exactly that conversation. The continue option instead reopens the most recent conversation. That suits a single-user script, but in a service handling many users the most recent session may belong to someone else, so use resume with a stored ID there. To branch without disturbing the original, set forkSession while resuming: the SDK starts a new session ID and leaves the original session as it was. Setting persistSession to false stops sessions being saved to disk, which means they cannot be resumed later.

    Checkpoint 3 of 5· Exam question

    An agent has already analyzed a codebase's authentication module in an existing session and produced a JWT-based migration plan. The team now wants to explore an alternative OAuth2-based approach in a separate line of investigation without losing the ability to continue the original JWT-focused thread later. Which approach satisfies both goals?

    Sources1234

    2.What a plugin bundles and what it costs

    A Claude Code plugin packages several extensions into one installable unit: commands, agents, skills, hooks, and MCP and LSP servers. Each part affects a session in a different way, so installing a plugin is two decisions at once, one about context and one about trust.

    How each part of an enabled plugin acts on your machine and on Claude
    ComponentWhat it does
    HooksRun as shell commands at lifecycle points, with your full user permissions, outside the sandbox
    MCP and LSP serversClaude Code connects to the MCP servers and gives Claude their tools; a stdio server runs as a process Claude Code starts, and Claude Code also starts the declared language servers
    bin/ directoryAdded to the PATH of the Bash tool's shell
    Skills, commands, agentsEnter Claude's context as instructions

    The context cost starts before you type anything. Skill descriptions and MCP tool names load at the start of every session. For plugins in Anthropic's official marketplace, the install screen shows two estimates: Every turn, what the plugin adds to each message, and When invoked, what its skills and agents add once Claude loads them. Timing also matters. If activating a plugin mid-session would invalidate the prompt cache, /reload-plugins warns you and leaves the plugin pending.

    Trust lasts beyond the moment you install. Your permission rules still apply to a call to a plugin's MCP tool or to an executable in its bin/, but hooks run unprompted with your full permissions. If auto-update is on for a marketplace, the files you reviewed can change on disk in the background.

    Where a plugin comes from sets how much review it needs. Marketplaces with Anthropic's official names are official, ones with its community names are community, and every other marketplace, including one your coworker or organization publishes, is third-party. Before installing, read the install summary of what the plugin will add. Afterwards, claude plugin uninstall removes it, and --keep-data preserves its data directory under ~/.claude/plugins/data/. In claude -p runs /plugin does not work, but plugins you already installed still load, and you manage them from the shell with claude plugin commands.

    Checkpoint 4 of 5· Check yourself

    Claude runs an executable from an enabled plugin's bin/ directory through the Bash tool. Which statement is accurate?

    Sources5678

    3.Plugin scopes and the surfaces that load them

    The install scope decides who gets the plugin. User scope, the default, enables it in every project on your machine. Project scope enables it for everyone who works in the repository. Local scope enables it for you in this repository only. A scope that takes precedence over the declaring one can override it: claude plugin disable formatter --scope local turns off a project-enabled plugin for you alone. In Claude Code, plugins install from the terminal, the desktop app, VS Code and cloud sessions. claude.ai chat and Cowork handle plugins through their own path.

    The Agent SDK has no install step. You list plugin directories in the plugins option, and only type: "local" is supported. Relative paths resolve against the cwd option. Check the init message to confirm what loaded: it lists the plugins, and plugin skills appear with the plugin name as a prefix, such as my-plugin:greet. That prefixed name is also how you invoke them. If your application manages the plugin's MCP connections itself, set skipMcpDiscovery (TypeScript). The SDK then loads the plugin's skills, hooks, agents and commands but skips its MCP servers.

    Loading two local plugins in a TypeScript Agent SDK sessiontypescript
    import { query } from "@anthropic-ai/claude-agent-sdk";
    
    for await (const message of query({
      prompt: "Hello",
      options: {
        plugins: [
          { type: "local", path: "./my-plugin" },
          { type: "local", path: "/absolute/path/to/another-plugin" }
        ]
      }
    })) {
      // Plugin commands, agents, and other features are now available
    }

    Checkpoint 5 of 5· Check yourself

    A team lead runs claude plugin install formatter@my-marketplace and wants every collaborator on the repository to get the plugin. Without a scope flag, what happens?

    Sources5839

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.Before switching to unrelated work, run /compact so Claude keeps a compressed memory of the earlier task.Why is that wrong?

      Unrelated work calls for /clear. Carrying old conversation forward, even as a summary, crowds out the next task's files and costs tokens on every message.

      Covered in Compact, clear or delegate: the session hygiene rule

    2. 2.A plugin's hooks and MCP servers run inside Claude Code's sandbox, so installing a plugin is low-risk.Why is that wrong?

      Claude Code runs both outside the sandbox, and command hooks run with your full user permissions.

      Covered in What a plugin bundles and what it costs

    Sources

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Compact with a focus: run /compact with instructions, like /compact focus on the auth bug fix, before starting a long new task.”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Delegate large reads: send research to a subagent so the file contents stay in its context window, not yours.”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Only the summary and a small metadata trailer come back.”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Files Claude read or edited | Claude Code re-reads up to five, most recently modified first”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Most startup content reloads automatically”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Old conversation crowds out the files you need next and costs tokens on every message.”
      ↩︎ Exam trap 1
      “Clear between tasks: run /clear when switching to unrelated work.”
      ↩︎ Prediction
      “Project-root CLAUDE.md and unscoped rules | Re-injected from disk”
      ↩︎ Checkpoint
    2. 2.
      “Resume from summary: runs /compact immediately.”
      ↩︎ Compact, clear or delegate: the session hygiene rule
    3. 3.
      “When resuming with resume, fork to a new session ID instead of continuing the original session”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Continue the most recent conversation”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “When false, disables session persistence to disk. Sessions cannot be resumed later”
      ↩︎ Compact, clear or delegate: the session hygiene rule
      “Must be 'local' (only local plugins currently supported)”
      ↩︎ Plugin scopes and the surfaces that load them
    4. 5.
      “Will install: the commands, agents, skills, hooks, and MCP and LSP servers the plugin adds.”
      ↩︎ What a plugin bundles and what it costs
      “Every turn is what the plugin adds to each message you send”
      ↩︎ What a plugin bundles and what it costs
      “Plugins you already installed do load.”
      ↩︎ What a plugin bundles and what it costs
      “Install for all collaborators on this repository (project scope): it’s enabled for everyone who works in this repository”
      ↩︎ Plugin scopes and the surfaces that load them
    5. 6.
      “command hooks execute shell commands with your full user permissions”
      ↩︎ What a plugin bundles and what it costs
      “A stdio MCP server runs as a process that Claude Code starts on your machine.”
      ↩︎ What a plugin bundles and what it costs
      “Claude Code runs hooks and MCP servers outside the sandbox.”
      ↩︎ Exam trap 2
      “a Bash command that runs an executable from the plugin’s bin/, are tool calls, so your permission rules apply to them.”
      ↩︎ Checkpoint
    6. 8.
      “--keep-data | Preserve the plugin’s persistent data directory”
      ↩︎ What a plugin bundles and what it costs
      “claude plugin disable formatter --scope local turns off a project-enabled plugin for you alone”
      ↩︎ Plugin scopes and the surfaces that load them
      “Installation scope: user, project, or local. Defaults to user”
      ↩︎ Checkpoint
    7. 9.
      “Relative paths: resolved relative to the cwd option”
      ↩︎ Plugin scopes and the surfaces that load them

    Ready to test yourself?

    Practise the 20 questions on this subdomain.

    Spotted a mistake, or was something unclear? Tell us.