YouTip LogoYouTip

Claude Code First Demo

## Getting Started with Claude Code: Your First Demo Once you have installed Claude Code and configured your API keys, you are ready to start using it. In this tutorial, we will walk through a simple, hands-on demo to help you get familiar with Claude Code's core capabilities, including code explanation, modification, and integration with VS Code. --- ## Setting Up a Demo Project First, let's create a minimal project directory and a simple Python file to use as our playground. Open your terminal and run the following commands: ```bash # Create a demo directory mkdir runoob-claude-demo cd runoob-claude-demo ``` Next, create a basic Python file: ```bash touch main.py ``` Open `main.py` in your favorite editor and add the following simple function: ```python def add(a, b): return a + b ``` --- ## Interacting with Claude Code ### 1. Asking Claude Code to Explain Code Navigate to your project directory in the terminal and launch the Claude Code interactive session: ```bash claude ``` Once the session starts, type the following prompt: > "Explain what the main.py file is doing in a way that a beginner can easily understand." Claude will read the code in your current directory and provide a clear, step-by-step explanation. !(https://www.runoob.com/wp-content/uploads/2026/01/c0eea48b-3529-4d57-ab32-7a8fa40161b9.png) --- ### 2. Asking Claude Code to Modify Code You can ask Claude to modify your code directly within the same session. Type the following prompt: > "Add type hints to this function and implement basic error handling." Claude will analyze the file and propose modifications. The output typically includes: * The updated code block. * An explanation of why the changes were made. You will then be prompted to choose one of the following actions: * **Accept/Apply:** Directly write the changes to the file. * **Adjust:** Manually tweak the suggested changes. * **Reject:** Decline the modifications. !(https://www.runoob.com/wp-content/uploads/2026/01/b39ec2f7-7206-4b10-a72d-292ed90fb3f8.png) --- ## Core Interaction Patterns When working with Claude Code, your prompts will generally fall into three main categories: ### 1. Explanatory Prompts Used for understanding existing codebases, legacy code, or complex logic. * *"Explain this block of code."* * *"Why was this function written this way?"* ### 2. Modification Prompts Used for refactoring, optimizing, or restructuring code. * *"Help me refactor this function."* * *"Split this large function into multiple smaller, reusable helper functions."* ### 3. Generative Prompts Used for writing new code, tests, or adding boilerplate logic. * *"Write a unit test case for this function."* * *"Add logging statements to track execution flow."* ### Recommended Prompt Template For safe and predictable code improvements, you can use this structured template: ```text Without changing the existing behavior, please optimize the readability of the file, and explain the specific modifications you made. ``` --- ## Troubleshooting: Fixing Directory Permissions If you are using macOS or Linux, you might occasionally encounter permission issues when Claude Code tries to write configuration files or manage projects. If you see an error similar to this: ```text Error: EACCES: permission denied, open ``` You can resolve it by resetting the ownership and permissions of the `.claude` directory. Run the following commands in your terminal: ```bash # 1. Fix ownership of the .claude directory sudo chown -R $(whoami) ~/.claude # 2. Grant read, write, and execute permissions to the owner chmod -R 755 ~/.claude # 3. Ensure the projects subdirectory is writable chmod -R 755 ~/.claude/projects ``` To verify that the permissions have been successfully updated, run: ```bash ls -la ~/.claude/ ``` --- ## Using Claude Code in VS Code If you prefer a graphical user interface over the command-line interface (CLI), you can install and use Claude Code directly inside Visual Studio Code. ### Step 1: Install the Extension Open VS Code, navigate to the Extensions Marketplace (`Ctrl+Shift+X` or `Cmd+Shift+X`), search for **Claude Code**, and click **Install**. !(https://www.runoob.com/wp-content/uploads/2025/12/cc-runoob-1.png) ### Step 2: Open the Claude Code Panel Once installed, click the **Claude Code** icon in the top-right corner of your editor to open the interactive panel: !(https://www.runoob.com/wp-content/uploads/2026/01/5c78e2a4-f9f4-4e38-91fa-d09ae892b9a4.png) ### Step 3: Start Chatting and Coding You can now interact with Claude Code directly in the sidebar, allowing you to ask questions, generate code, and apply refactoring suggestions seamlessly alongside your active editor window. !(https://www.runoob.com/wp-content/uploads/2026/01/22ba1d61-4b00-4d5c-ac99-d0831a6f6eeb.png)
← Claude Code BasicClaude Code Install β†’