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
Jul 16, 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

    Launch Claude Code

    Launching Claude Code is quite simple. In the Terminal, enter the following command

    claude
    

    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.

    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 is fickle, and 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
    

    When 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, and when asked choose the Yes option:

    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.
    

    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.
  4. Challenge

    Human intervention signals

    Within the CLAUDE.md file you will see two sections added by Claude when you prompted it to update the markdown file earlier. These two 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.

    --- ### Manual changes

    Paste in the following at the end of CLAUDE.md. (If you're having difficulty selecting the text below, it may be easier to select the text from the bottom up.):

    ## Human Intervention Signals
    
    Claude Code can complete many development tasks autonomously, but some situations require human judgment before proceeding. When any of the following conditions occur, Claude should pause and request guidance instead of making assumptions.
    
    ### Request Human Intervention When
    
    - Project requirements conflict with the existing implementation or test suite.
    - Multiple valid solutions exist and the correct choice depends on business requirements.
    - A proposed change would modify a public API or introduce a breaking change.
    - A command would install new packages, delete files, modify Git history, or access external resources.
    - A change could impact security, privacy, or sensitive data.
    - The requested task falls outside the project's defined scope.
    
    ### Continue Autonomously When
    
    - The requested change is well-defined and aligns with project instructions.
    - Tests clearly identify the expected behavior.
    - The fix is localized and can be verified by running the existing test suite.
    - The change does not require elevated permissions or external systems.
    - Claude can verify the outcome through automated testing or other project validation tools.
    

    Manual changes once again offer greater control as you can control both human intervention signals and autonomous signals. This allows greater control over specific states of the model, and additional commands to ask for human intervention in unknown scenarios can be appended as well, allowing for complete control over the AI's high dimensional choices.

  5. 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.

    --- ### Method 1: Claude generation

    In the Terminal, paste in the following at the Claude Code CLI prompt, choosing Yes when 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 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.

    --- ### Method 2: Manual changes

    Similar to before, for more specific or granular alterations to the markdown, manual changes to manage tokens and set context can be added.

    Paste the following at the end of the CLAUDE.md file:

    
    ## Token and Context Management
    
    To keep long-running agentic sessions focused and efficient:
    
    - Keep summaries brief and focused on decisions, completed work, and remaining tasks.
    - Do not repeat large code blocks or previously reviewed files unless necessary.
    - Reference existing project files instead of reproducing their contents.
    - Summarize the current state before switching to a new task.
    - Use the `/compact` command after major milestones to reduce conversation history while preserving important context.
    - Ask for clarification whenever required information is missing instead of making assumptions.
    - Keep project memory concise so more of the available context window can be used for the current task.
    
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