Your First 10 Prompts

Do not just read - open Claude Code right now and type these prompts. By the end of this lesson you will have generated real code, explained unfamiliar code, and fixed a bug using AI.

Beginner 15 min hands-on Lesson 5 of 20

Before You Start

  1. Open a terminal
  2. Create a test folder: mkdir ai-practice && cd ai-practice
  3. Start Claude Code: claude
  4. Type each prompt below, press Enter, and observe the result
These prompts use PHP/Python as examples

The principles work in any language. If you prefer JavaScript, Ruby, or Go, substitute accordingly. The AI understands all common languages equally well.

Prompts 1-2: Ask Questions

Start with the simplest possible prompts - asking the AI questions.

Prompt 1 - Language question
> What is the difference between POST and GET in a PHP form?
  When should I use each one?

What to notice: The AI gives a clear, contextual explanation. Compare this to a Google search - you get a direct answer in seconds, tailored to PHP, without reading 5 different articles.

Prompt 2 - Concept question
> I'm new to PHP. Can you explain what a PDO prepared statement is
  and show me a simple example of using one to insert a user into a
  MySQL database?

What to notice: The AI adjusts its explanation to your stated experience level ("I'm new to PHP"). You get a working code example alongside the explanation.

Prompts 3-4: Generate Code

Now create actual code files.

Prompt 3 - Create a file
> Create a PHP file called calculator.php that:
  - Has a form with two number inputs and a dropdown to select add/subtract/multiply/divide
  - When submitted, calculates the result and displays it below the form
  - Handles division by zero with an error message
  - Uses Bootstrap 5 for styling

What to notice: The AI creates the entire file. Accept the permission to write the file. Open it in your browser and test it. This would take a beginner 45-60 minutes to write from scratch.

Prompt 4 - Generate a function
> Write a PHP function called formatIndianPhone($number) that:
  - Takes a phone number string (may have spaces, dashes, +91 prefix)
  - Returns it in the format: +91 XXXXX XXXXX
  - Returns false if the number is invalid
  Include 5 test cases showing input/output

What to notice: The AI writes the function AND writes test cases. Always ask for test cases when generating functions - they help you verify the output immediately.

Prompts 5-6: Explain Code

Use AI to understand code you did not write (or code you wrote but have forgotten).

Prompt 5 - Explain this code
> Explain what this PHP code does, line by line, in simple terms:

$stmt = $pdo->prepare("SELECT * FROM users WHERE email = ? AND active = 1");
$stmt->execute([$email]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if ($user && password_verify($password, $user['password_hash'])) {
    $_SESSION['user_id'] = $user['id'];
    header("Location: /dashboard");
    exit;
}

What to notice: The AI explains every line. This skill is invaluable when working with inherited codebases - just paste any confusing code and ask for an explanation.

Prompt 6 - Explain a concept in context
> In the calculator.php file you just created, what does the
  htmlspecialchars() function do and why is it important?

What to notice: The AI refers back to code it created in this session and explains a security concept in context. This is better than a generic explanation because it relates to your specific code.

Prompts 7-8: Fix Code

The most common daily task - fixing something broken.

Prompt 7 - Fix with an error message
> I have this PHP code and it throws this error. Fix it.

Code:
$items = ['apple', 'banana', 'cherry'];
echo "The second item is: " . $items[3];

Error:
Warning: Undefined offset: 3 in calculator.php on line 2

What to notice: Always include the exact error message. The AI immediately understands the problem (array index 3 does not exist in a 3-item array, which uses indices 0, 1, 2) and fixes it.

Prompt 8 - Fix behavior (not an error)
> In my calculator.php, when I divide 10 by 3, the result shows
  as "3.3333333333333". I want it to show only 2 decimal places.
  Fix it.

What to notice: Not all bugs produce error messages. Describe the wrong behavior in plain English. The AI knows to use round() or number_format() to fix this.

Prompts 9-10: Build a Feature

Now build something real - a complete small feature from scratch.

Prompt 9 - Build a complete page
> Build a complete PHP contact form page called contact.php with:
  - Name, email, phone, message fields
  - Validation: all fields required, email must be valid format
  - On submission: save to a MySQL table called contacts (id, name, email, phone, message, created_at)
  - Use PDO with a connection from config/db.php
  - Show success message after saving
  - Bootstrap 5 styling with a clean card layout
  - Redirect back if called directly without POST

What to notice: This single prompt builds a complete, production-usable contact form. The level of detail in the prompt directly determines the quality of the output.

Prompt 10 - Iterate on what you built
> Update the contact.php we just created:
  1. Add a honeypot spam field (hidden, should be empty on submit)
  2. Rate limit: block if the same IP submits more than 3 times in 10 minutes
     (track in a contacts_rate_limit table)
  3. Send an email notification to admin@mysite.com on each submission
     using PHP mail()

What to notice: Follow-up prompts that reference previous work ("the contact.php we just created") give the AI context to extend existing code rather than start over. This is how real development works with AI - build, then extend.

What Next

You have just used AI to:

  • Answer programming questions in seconds
  • Generate a complete working calculator from one prompt
  • Explain unfamiliar code line by line
  • Fix bugs with and without error messages
  • Build a complete contact form with security features

The next lesson teaches you how to read and verify AI output so you know when to trust it and when to question it.

Frequently Asked Questions

Rephrase and try again. Sometimes the AI misinterprets the task. Break it into smaller steps. Or ask "what information do you need to do this?" - the AI will often tell you exactly what context is missing.

This is normal - always test AI code. Copy the error message and paste it back as a follow-up prompt: "I ran the code and got this error: [error message]. Fix it." The AI will correct the issue, often immediately.

Yes - this is one of the most useful habits. After getting code, ask "Explain what each function does in simple terms" or "Walk me through this step by step." You should understand every line of code in your project.