claude_prompt_examples.md•5.33 kB
# Example Claude Interactions with Prompts
This document shows examples of how Claude can effectively use the interactive prompt capabilities when helping users with various tasks.
## Example 1: Creating a Configuration File
**User**: Can you help me create a config file for my project?
**Claude**:
```
I'd be happy to help you create a configuration file for your project. Let me ask you a few questions to get started.
[Call prompt("custom", message="What type of project are you working on? (e.g., Node.js, Python, React, etc.)")]
Thanks for letting me know. Now I'll ask about some specific configuration options.
[Call prompt("custom", message="What environment variables do you need in your configuration? Please list them one per line with optional default values (e.g., PORT=3000).")]
Great! One last question before I create the file.
[Call prompt("custom", message="Where would you like to save this configuration file? (e.g., .env, config.json, etc.)")]
Thanks for providing all that information. I'll create your configuration file now.
[Call interactive_write(file_path)]
I've successfully created your configuration file with the settings you specified. Is there anything else you'd like to add or modify?
```
## Example 2: Finding and Editing a Specific File
**User**: I need to update one of my JavaScript files but I'm not sure which one contains the function I need to change.
**Claude**:
```
I can help you find and update the JavaScript file. Let's start by identifying which file contains the function you want to modify.
[Call prompt("custom", message="What is the name of the function you're looking to change?")]
Thanks! Let me search for JavaScript files that contain this function.
[Call find(".", "*.js", file_type="f")]
I found several JavaScript files. Let me check each one for your function.
[For each file, call grep(function_name, file_path)]
I found the function in these files:
[List files that contain the function]
Let's select which file you want to edit:
[Call select_file(".", pattern_based_on_search_results)]
Great! Here's the current content of the file:
[Call read(selected_file)]
Now, let me ask what changes you want to make:
[Call get_file_content(selected_file)]
Before I save these changes, let me confirm:
[Call confirm_overwrite(selected_file)]
I've updated the file with your changes. The function has been modified as requested.
```
## Example 3: Project Initialization
**User**: Can you help me start a new web application project?
**Claude**:
```
I'd be happy to help you set up a new web application project. Let's gather some information about what you want to create.
[Call init_project()]
Great! I've created a new project directory with the basic structure. Here's what I've set up:
- Created a directory structure for your web application
- Added a README.md file with project information
- Set up basic configuration files
Would you like me to help you create any specific components or files for your web application?
[Call prompt("custom", message="What feature would you like to implement first in your web application?")]
Let's create that feature. I'll help you set up the necessary files:
[Create relevant files based on user response]
Your initial project setup is complete! Here's a summary of what we've created:
[List files and directories created]
Would you like me to explain how to run or further develop this project?
```
## Example 4: Guided File Management
**User**: I have a bunch of log files that I need to organize.
**Claude**:
```
I can help you organize your log files. Let's start by identifying them and determining how you'd like them organized.
[Call find(".", "*.log", file_type="f")]
I found the following log files:
[List log files found]
[Call prompt("custom", message="How would you like to organize these log files? Options:\n1. By date\n2. By type/category\n3. Combine into a single archive\n4. Something else (please specify)")]
Based on your choice, let's proceed with organizing the files:
[For option 1: Parse dates from filenames and organize accordingly]
[For option 2: Prompt for categories and organize]
[For option 3: Create a compressed archive]
[For option 4: Custom solution based on response]
[Call prompt("custom", message="Would you like me to create a backup of these files before reorganizing them? (yes/no)")]
[If yes, create backup]
Now I'll organize your files as requested:
[Perform organization operations]
The organization is complete! Here's the new structure:
[Show new organization]
Is there anything else you'd like me to help you with regarding these files?
```
## Best Practices Demonstrated
These examples demonstrate several best practices:
1. **Clear communication**: Claude explains what it's doing at each step
2. **Progressive disclosure**: Complex tasks are broken down into manageable steps
3. **Confirmation for important actions**: Changes are confirmed before being applied
4. **Contextual prompts**: Questions are based on previous responses
5. **Helpful summaries**: Results are summarized after completion
6. **Offering additional help**: Claude offers to assist with related tasks
By following these patterns, Claude can provide a helpful and intuitive experience when using interactive prompts to assist users with filesystem tasks.