Skip to content

Commit 97a42c3

Browse files
ktaletskmfisher87
andauthored
Chapter corrections (#89)
* explain environment variables h/t @dbouquin * note about custom cursor instructions h/t @dbouquin * add a basic prompting guide fix colon fences in myst * Update 04-materials/05-developing-with-ai.md Co-authored-by: Matt Fisher <[email protected]> * Refine prompt fundamentals section in 05-developing-with-ai.md - Removed redundant cursor-specific notes for clarity. - Enhanced descriptions for intent, state, and selections to improve guidance on effective prompting. * remove Windows instructions for env vars --------- Co-authored-by: Matt Fisher <[email protected]>
1 parent 3f1c85d commit 97a42c3

File tree

2 files changed

+61
-9
lines changed

2 files changed

+61
-9
lines changed

03-vocabulary.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,9 @@ ESLint
136136

137137
Prettier
138138
: An automatic code {term}`formatter <formatter>` that enforces consistent style across JavaScript, TypeScript, JSON, and CSS files. JupyterLab's extension template includes Prettier to ensure all code follows the same formatting conventions.
139+
140+
Environment variable
141+
: A key–value setting in the operating system environment that shells and programs inherit.
142+
For a single command use `NAME=value command`; for the current shell and its child processes use `export NAME=value` (lost when the shell exits); to persist across sessions add `export NAME=value` to your shell startup file (e.g., `~/.zshrc` or `~/.bashrc`).
143+
Inspect with `echo $NAME`; remove with `unset NAME`.
139144
:::

04-materials/05-developing-with-ai.md

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# 🤖 5 - Developing extensions with AI assistance
22

3-
::::{hint} Learning objectives
3+
:::{hint} Learning objectives
44
- Use agentic AI tools (Cursor and Claude Code) to build and evolve JupyterLab extensions using product‑manager style prompts with context, constraints, and acceptance criteria
55
- Configure and verify AGENTS.md and environment conventions so tools follow project patterns
66
- Implement and iterate on features across frontend and backend with phased plans; manage model selection/context, and use AI to diagnose and fix build/runtime errors
7-
::::
7+
:::
88

9-
::::{tip} Outcome
9+
:::{tip} Outcome
1010
After this module, you will have:
1111
- Implemented an image‑editing feature in our extension, verified it in JupyterLab, and committed your changes
1212
- Practiced one‑shot vs structured prompting, model selection, and context management; got comfortable reviewing, iterating on, and rolling back AI‑generated edits
1313
- Gained confidence to continue exploring extension ideas primarily by prompting, while being able to understand and edit the generated code
14-
::::
14+
:::
1515

1616
:::{note} Inspired by...
1717
:class: dropdown
@@ -50,6 +50,29 @@ You would never hire a developer and expect absolute perfection in their creativ
5050
- Treat errors as learning opportunities for both you and the AI
5151
- Don't be afraid to roll back to the beginning and start over if AI doubled down on a wrong path
5252

53+
### ✍️ Prompt fundamentals
54+
55+
Keep prompts short, specific, and grounded in the exact code you're changing.
56+
57+
- **Intent + state**: State what you want and show the current code (select lines or attach files)
58+
- **(Cursor specific) Point with `@`**: Reference files/folders/docs (e.g., `@src/index.ts`, `@plans/...`, `@JupyterLab docs`)
59+
- **Constrain**: Provide acceptance criteria and constraints (APIs to use, error handling)
60+
- **Iterate**: Prefer small steps; ask follow‑ups over one giant prompt
61+
- **(Cursor only) Selections win**: Selecting code before asking gives that text highest priority in context
62+
63+
:::{dropdown} Examples (before → better)
64+
**Before:** "Add image editing."
65+
66+
**Better:**
67+
```
68+
Extend @src/widget.ts to add a grayscale button that calls the new backend route.
69+
Acceptance:
70+
- Adds button to existing toolbar (same styling)
71+
- Calls /edit-image?op=grayscale
72+
- Updates image preview on success
73+
```
74+
:::
75+
5376
### 🧠 Understanding {term}`LLMs <LLM>` (large language models)
5477

5578
AI coding assistants are powered by **Large Language Models ({term}`LLMs <LLM>`)** — neural networks trained on vast amounts of text and code. These models can:
@@ -205,9 +228,9 @@ We'll work with **Cursor** to demonstrate the AI-assisted workflow, then repeat
205228
- **LLM Options:**
206229
- Built-in models (Claude Sonnet 4.5, GPT-5, Gemini 2.5 Pro and more) with Cursor subscription
207230
- **Best for:** Developers who want a polished, GUI-driven experience
208-
::::{dropdown} Alternatives
231+
:::{dropdown} Alternatives
209232
- [Windsurf](https://codeium.com/windsurf) (free tier, \$15/mo Pro), [GitHub Copilot Workspace](https://github.com/features/copilot) (\$10-39/mo), [Cline](https://cline.bot/) (VS Code extension, free), [Continue](https://continue.dev/) (VS Code/JetBrains extension, free or \$10/mo Teams), [Roo Code](https://roocode.com/) (VS Code extension, free or \$20/mo Pro), [Kilocode](https://kilocode.ai/) (VS Code/JetBrains, free or \$29/user/mo Teams), [Replit Agent](https://replit.com/) (cloud-based)
210-
::::
233+
:::
211234
- **Download:** [cursor.com](https://cursor.com/)
212235

213236
#### 2. 💻 **Claude Code**
@@ -216,9 +239,9 @@ We'll work with **Cursor** to demonstrate the AI-assisted workflow, then repeat
216239
- Requires Claude subscription or Anthropic API key. Can also work through cloud providers, like Amazon Bedrock
217240
- Works with Opus 4.1, Sonnet 4.5, Haiku 4.5, and other Claude models
218241
- **Best for:** CLI warriors who live in the terminal
219-
::::{dropdown} Alternatives
242+
:::{dropdown} Alternatives
220243
- [Gemini CLI](https://github.com/google-gemini/gemini-cli) (free tier available), [Cline](https://github.com/cline/cline) (VS Code extension with CLI mode, free), [Continue](https://github.com/continuedev/continue) (IDE/terminal/CI agent, free), [Plandex](https://github.com/plandex-ai/plandex) (designed for large projects), [aichat](https://github.com/sigoden/aichat) (all-in-one LLM CLI), [GitHub Copilot CLI](https://github.com/github/copilot-cli), [Aider](https://github.com/Aider-AI/aider) (Git-integrated, open-source), [Google Jules](https://jules.google/) (async background agent, beta)
221-
::::
244+
:::
222245
- **Install:** See [official setup instructions](https://docs.claude.com/en/docs/claude-code/setup)
223246

224247
:::{note} Further Reading
@@ -376,7 +399,7 @@ We recommend you sign up for a free Hobby plan for this workshop! You'll have on
376399

377400
We will be using Claude models provided by AWS Bedrock in this tutorial.
378401

379-
**Required environment variables:**
402+
**Required {term}`environment variables <environment variable>`:**
380403

381404
```bash
382405
# macOS/Linux
@@ -693,6 +716,13 @@ Before we dive into our structured approach, let's witness what modern AI can ac
693716

694717
With the right context and a detailed prompt, AI can build complete features in minutes. Here's a prompt that could generate our entire image editing extension:
695718

719+
:::{dropdown} Cursor prompting quick tips
720+
- **Use @ precisely**: `@code` (symbol), `@file` (e.g., `@src/index.ts`), `@folder` (e.g., `@src/utils/`). This steers Cursor to the exact context you want.
721+
- **Reference specific lines**: Select the lines and press `Cmd/Ctrl + L` to add them to the current chat as an `@` selection. Want a fresh chat? Press `Cmd/Ctrl + N` — the `@` reference carries over. Selection is prioritized; line‑range mentions via `@` aren’t supported.
722+
- **Bias auto‑context**: Cursor auto‑pulls from your session (active file, recent edits). Keep the relevant file active and close noisy, unrelated large files. Use `@` when you need deterministic precision.
723+
- **Docs as context**: After adding docs to Cursor, mention them with `@` (e.g., `@JupyterLab API`).
724+
:::
725+
696726
```
697727
Extend this image viewer extension to add image editing capabilities:
698728
@@ -733,6 +763,14 @@ When you give this prompt to an AI agent like Cursor or Claude Code, it will typ
733763

734764
Send the prompt and watch as it generates the entire feature. **In about 2-3 minutes**, you will have a fully functional image editor!
735765

766+
:::{note} Cursor customizations may change behavior
767+
If you have custom Cursor Instructions, team rules, model defaults enabled, the agent's behavior and outputs may differ from the workshop steps and screenshots. For a consistent experience during the workshop:
768+
- Temporarily disable or minimize global instructions
769+
- Ensure the repo's `AGENTS.md` remains the primary rules source
770+
- Match the recommended models in this chapter
771+
- Reset per-project settings if results seem inconsistent
772+
:::
773+
736774
**Review the generated code**
737775
- Cursor will suggest changes across multiple files
738776
- Read through each change carefully
@@ -995,6 +1033,15 @@ As you work through phases, keep an eye on **context window percentage** (shown
9951033
- ✅ Major refactoring complete
9961034
:::
9971035

1036+
:::{dropdown} Add Jupyter docs to Cursor (recommended)
1037+
1. Open Cursor Settings → Docs → Add Docs
1038+
2. Add:
1039+
- JupyterLab API: `https://jupyterlab.readthedocs.io/en/latest/api/index.html`
1040+
- Lumino APIs: `https://lumino.readthedocs.io/en/latest/api/index.html`
1041+
- Jupyter Server API: `https://petstore.swagger.io/?url=https://raw.githubusercontent.com/jupyter/jupyter_server/main/jupyter_server/services/api/api.yaml`
1042+
3. Use `@JupyterLab API` (or `@Lumino API`) in chat to use precise documentation when implementing a function.
1043+
:::
1044+
9981045
1. **Start a NEW chat** for Phase 1 (`Cmd/Ctrl + L` to focus on chat panel, then `Cmd/Ctrl + N` to start a new chat)
9991046

10001047
2. **Reference the plan:**

0 commit comments

Comments
 (0)