Skip to main content
Reading progress: 0%

Lesson 5.1: Development Environment, Terminal, Packages, and Environment Variables

Lesson Quick-Jump (10 Sections)

1. What Are We Learning?​

In this lesson, you will learn how to:

  • Understand your development environment (IDE, AI coding agent, runtime, terminal).
  • Use basic terminal commands comfortably without fear.
  • Understand what package managers do (and how to stay safe when installing packages).
  • Configure environment variables safely using .env and .env.example.

2. Why Does It Matter?​

info

Many beginners get stuck on day one because they don't know where to type commands, why a project needs packages installed, or where secret API keys belong. Worse, beginners sometimes paste secret keys straight into code files and upload them publicly to GitHub—which bots scan and steal within minutes.

Getting your local workspace clean and safe once makes every future coding session smooth.


3. Simple Explanation for a Complete Beginner​

Think of your development environment as a clean carpenter's workshop on your computer:

  1. The IDE (Code Editor): Where you read files, see folder trees, and talk to your AI coding agent (see AI-CODING-AGENTS.md).
  2. The Terminal (Command Line): A text box inside your editor where you give direct instructions to your computer—like "go into this folder," "install packages," or "start the local server."
    • Four commands cover 80% of daily use:
      • pwd — "Where am I right now?" (prints current folder path)
      • ls (or dir on Windows Command Prompt) — "What files are in this folder?"
      • cd folder-name — "Move into folder-name" (cd .. moves up one level)
      • Run commands like npm run dev or python app.py — "Start the app"
  3. Runtime & Package Manager:
    • A runtime (such as Node.js or Python) runs your code on your computer.
    • A package manager (such as npm for JavaScript/TypeScript or pip for Python) downloads helpful open-source building blocks (dependencies) listed in a manifest file (package.json or requirements.txt).
  4. Environment Variables (.env): Values your app needs that either vary by location (local laptop vs. live server) or must stay secret (database passwords, API keys).
    • .env holds your real local secrets and is NEVER committed to GitHub.
    • .env.example holds dummy placeholder names (like DATABASE_URL=your_url_here) and IS committed so anyone setting up the project knows which variables are required.

4. Practical Example​

Suppose your app connects to a database and sends transactional emails.

Inside .env (private on your computer ONLY):

DATABASE_URL="postgresql://user:real_local_password@localhost:5432/habit_app"
EMAIL_API_KEY="sk_live_secret_12345"

Inside .env.example (safe to share on GitHub):

DATABASE_URL="postgresql://user:password@localhost:5432/dbname"
EMAIL_API_KEY="replace_with_your_email_provider_key"

Inside .gitignore (tells Git what to never upload):

.env
.env.local
node_modules/
__pycache__/

5. Step-by-Step Instructions​

  1. Install your chosen runtime (e.g., Node.js LTS or Python) from its official website, and install Git if not already installed.
  2. Open your code editor / IDE and open its built-in Terminal panel.
  3. Verify your tools are installed by running version checks in the terminal:
    • git --version
    • Plus your stack's runtime check (for example node --version and npm --version, or python3 --version and pip --version).
  4. Practice navigating with pwd, ls, and cd until you feel comfortable knowing which folder your terminal is currently inside.
  5. Create a .env.example habit: Whenever an AI agent adds a new config value or API key requirement, insist it updates .env.example with a placeholder and confirms .env is listed in .gitignore.

6. Ready-to-Use AI Prompt​

Context:
I am setting up my development environment on [Windows / macOS / Linux] for this tech stack: [name your stack from Phase 4].
I am a beginner using the terminal for the first time.

Objective:
Give me an exact, safe setup checklist to verify my runtime, package manager, and environment variable setup before creating the project.

Boundaries:
- Do NOT ask me to paste real passwords or API keys into chat.
- Explain what every terminal command does before asking me to run it.
- Clearly mark which commands are specific to my OS or stack.

Expected Output:
1. Exact commands to check if my runtime, package manager, and Git are installed properly.
2. A starter `.gitignore` and `.env.example` tailored to my chosen stack.
3. Short plain-English explanation of what each installed tool does.

7. What to Expect from the AI Agent​

Good ResponseWarning Sign
The AI explains each terminal command cleanly (e.g., "This checks your Node version without changing any files") and provides an explicit .gitignore covering .env and dependency folders.The AI tells you to run curl ... | bash from an unfamiliar URL, asks you to disable security permissions, or hardcodes a sample secret directly in source code instead of using environment variables.

8. What You Must Personally Verify​

  • Terminal location: Always check pwd before running install or delete commands so you are in the right folder.
  • Package sanity check: Whenever an AI suggests installing a new package, ask why it is needed and verify the package name is a real, well-known library (AI agents occasionally hallucinate fake package names).
  • Secret safety (Mandatory rule): Never paste real API keys, passwords, or .env contents into AI chat or code files.

9. Common Mistakes​

  1. Running commands from the wrong folder: Running npm install in your home directory instead of inside your project folder creates stray files in the wrong place.
  2. Committing node_modules/ or .env to GitHub: node_modules/ contains thousands of downloadable files that belong only on your machine, and .env leaks your secrets.
  3. Ignoring terminal error messages: Red text in the terminal usually tells you exactly what is missing (e.g., wrong folder, command not found). Read the first error line carefully instead of retrying blindly.

10. Small Practical Exercise​

  1. Open your IDE's terminal.
  2. Run pwd, ls, and git --version (plus your stack's runtime check).
  3. Create a temporary practice folder (mkdir setup-test && cd setup-test), verify pwd shows you are inside it, create a sample .env.example and .gitignore using the AI prompt above, then check with ls -la that hidden dotfiles like .gitignore appear.

Completed the exercise? Track your progress

Check off this lesson in PROGRESS-CHECKLIST.md once you have verified every step in Section 8.