Featured resource
2026 Tech Forecast
2026 Tech Forecast

1,500+ tech insiders, business leaders, and Pluralsight Authors share their predictions on what’s shifting fastest and how to stay ahead.

Download the forecast
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
Labs

Claude Code and the Agentic Loop

In this lab, you'll explore agentic AI using the Claude Code CLI. You'll observe how an AI agent plans, acts, verifies its work, and self-corrects while completing a coding task. You'll configure project memory and permission controls, identify when Claude can work autonomously versus when it requires human intervention, and apply context management techniques to keep long-running sessions focused. By the end of the lab, you'll have hands-on experience using the Claude Code CLI as an agentic development assistant while following best practices for safe and effective autonomous workflows.

Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 08, 2026
Duration
45m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Introduction

    In this lab, you'll explore agentic AI using the Claude Code CLI. You'll observe how an AI agent plans, acts, verifies its work, and self-corrects while completing a coding task. You'll configure project memory and permission controls, identify when Claude can work autonomously versus when it requires human intervention, and apply context management techniques to keep long-running sessions focused.

    By the end of the lab, you'll have hands-on experience using the Claude Code CLI as an agentic development assistant while following best practices for safe and effective autonomous workflows.

  2. Challenge

    Agentic loop

    Claude's initial scope is limited by the directory you launch it from, only accessing subdirectories unless prompted otherwise. (You are launching it from the workspace directory, where you will be initially when you start the lab.)

    Once launched, Claude will display the following:

    • the Claude Code version
    • the model being used

    Prompts will all be sent to Claude, and are similar to any other LLM; for the most part, no additional syntax is required.

    --- ### Enter a prompt

    1. Now enter the following prompt at the Claude Code CLI:

      The test suite is failing for calculator.py.
      
      Please:
      
      1. Explain your debugging plan before making changes.
      2. Identify the root cause.
      3. Implement the smallest possible fix.
      4. Run the test suite.
      5. If the tests still fail, inspect the output and correct your 
         solution.
      6. Summarize what changed.
      


      The prompt provided is a general prompt allowing you to see the agentic loop, and see clearly what Claude is doing.

      Note: Throughout the lab, the Claude Code CLI may render incorrectly. You can press Control+L to help clear the clutter.

    2. When prompted, choose the Yes option. (Press the associated number. For example, if the prompt is 1. Yes, press the 1 key.)

    Expect several prompts asking for your permission to access and read files. This works as a barrier to help the model stay focused, as well as a privacy restriction to ensure the model does not overstep its current permissions.

    (The following is likely not needed, but read further if you need some help accepting the prompts.

    You will receive prompts similar to the following:

    • running a python shell command
    • running python3 (This one may or may not be shown; sometimes Claude will figure out on its own to run python3.)
    • editing the given Python code

    If you get a more all-encompassing prompt, choose those. For example, you may get 2. Yes, and don’t ask again for: python *, in which case you'd press 2.

    When running Claude outside this lab, do consider what permission to provide before proceeding.)

  3. Challenge

    Permission scopes and human intervention

    Claude Code can act autonomously inside a project, but developers should define clear boundaries before allowing it to inspect files, edit code, or run commands. In this Step, you'll set permission scopes using the CLAUDE.md file so Claude knows what behavior is allowed, and will review those permission controls.

    The goal is to constrain Claude's autonomous behavior while still allowing it to complete useful development tasks safely.

    --- ### Create CLAUDE.md

    You will generate a markdown file to control Claude's behavior.

    Within the Claude Code CLI enter the following command:

    /init
    

    If Claude asks you if you want to create the markdown file, choose the Yes option.

    • Claude Code includes the /init command, which analyzes your project and creates a starter CLAUDE.md file.

    • The generated file typically includes a project summary.

    • It also includes recommendations for working within a repository. (You won't be using a repository for this lab.)

    • You can then customize it with your own instructions.

    You can use the FILETREE, and from there open the CLAUDE.md file to see the initial architecture added to the markdown file. Claude will have identified the architecture and valid commands.

    --- ### Method 1: Claude generation

    The pregenerated markdown file is a useful start, but can be altered to define scope, from which Claude can have a source of persistent truth to always reference.

    Provide Claude with the following prompt for updating its own CLAUDE.MD file:

    Include:
    - A brief description of the project.
    - A requirement to explain your plan before editing code.
    - A requirement to run pytest after every code change.
    - Instructions to keep edits small and focused.
    - A list of actions that require human approval, including installing 
      packages, deleting files, and changing tests.
    - A section describing when human intervention is required.
    

    (If prompted, choose the Yes option.)

    Once completed, the Claude markdown file will have been updated with working conventions that limit the scope of changes. These working conventions also specify when human intervention is required, as the markdown information is persistent across launches of Claude.

    --- ### Method 2: Manual changes

    For more specific control, you can manually alter the markdown file:

    1. If you haven't yet, open the markdown file: In the FILETREE, double-click CLAUDE.md.
    2. Scroll to the bottom of the file, and paste in the following text:
      
      ## Context Management
      
      - Keep summaries brief.
      - Remember only decisions, constraints, and completed work.
      - Do not repeat large code listings unless requested.
      - When switching tasks, summarize the current state before
        continuing.
      - Prefer referencing existing files instead of copying their
        contents.
      

    Context management similar to this will allow for greater control of token and memory usage for referencing files, and limit the scope of work for Claude, allowing more focused work.

    Overall,

    • additions generated by Claude Code can help with outlining and formatting,
    • while manual additions can get more specific and develop more granular changes per specific project or product.

    --- ### The /permissions command

    The /permissions command provides more granular control over what the agentic AI is allowed to access and work with.

    Instead of having generic rules like those specified above, /permissions uses more specific rules. For example, you can specify which file types the model is allowed to access or modify, as well as which file types are denied completely.

    You can control granularity, and have more broad rules. For example, a Bash(aws *) deny restriction would deny all attempts at using aws. More granular aws permissions would be overshadowed by this broad command.

  4. Challenge

    Token, memory, and context management

    As an agentic coding session grows, the amount of conversation history increases. Without context management, an AI agent may spend more time processing old information, repeat work, or lose focus on the current objective.

    Claude Code supports several techniques for managing long-running sessions, including concise project memory, periodic summaries, and the /compact command. In this step, you'll add project instructions that encourage efficient context usage while preserving the information needed to continue working effectively.

    --- ### Use /compact

    1. In the Terminal, run /compact.

      This should help compact the information from earlier, likely making the CLAUDE.md file more concise, and should give you an example of how compact will function.

    2. Paste in the following at the Claude Code CLI prompt, choosing Yes if prompted:

      Update the CLAUDE.md file by adding a section titled "Token and
      Context Management."
      
      Include best practices that help maintain long-running coding
      sessions by:
      - Keeping summaries concise.
      - Remembering only important project decisions and completed work.
      - Avoiding repetition of previously reviewed code.
      - Summarizing progress before changing tasks.
      - Using `/compact` after major milestones to reduce conversation
        history.
      - Asking for clarification when important context is missing
        instead of making assumptions.
      
      Return only the updated section and insert it into the existing
      CLAUDE.md file.
      

      This instructs Claude to use /compact periodically.

    This basic prompt creates a section in the markdown file that adds more context, and allows for token and memory management.

    Claude should then update the project memory with guidance that helps manage context throughout longer development sessions.

    You would want to review the generated section before accepting it. Project memory should remain concise and contain only durable instructions that are useful across multiple coding sessions.


  5. Challenge

    Human intervention signals

    Within the CLAUDE.md file you will very likely see two sections added by Claude when you prompted it to update the markdown file earlier (AI is non-deterministic, so your results may differ). These additions break out the human intervention into actions requiring humans, and actions to ask human permission.

    The tasks already specified within the markdown are fairly generalized standards, and can be altered with the granularity of specific files. Broad general ideas should be avoided, as the AI can have a higher chance of misclassifying these boundaries and proceeding without the proper human intervention.


About the author

I am, Josh Meier, an avid explorer of ideas an a lifelong learner. I have a background in AI with a focus in generative AI. I am passionate about AI and the ethics surrounding its use and creation and have honed my skills in generative AI models, ethics and applications and thrive to improve in my understanding of these models.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight