You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 03-vocabulary.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -136,4 +136,9 @@ ESLint
136
136
137
137
Prettier
138
138
: 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`.
Copy file name to clipboardExpand all lines: 04-materials/05-developing-with-ai.md
+56-9Lines changed: 56 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,17 @@
1
1
# 🤖 5 - Developing extensions with AI assistance
2
2
3
-
::::{hint} Learning objectives
3
+
:::{hint} Learning objectives
4
4
- 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
5
5
- Configure and verify AGENTS.md and environment conventions so tools follow project patterns
6
6
- 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
+
:::
8
8
9
-
::::{tip} Outcome
9
+
:::{tip} Outcome
10
10
After this module, you will have:
11
11
- Implemented an image‑editing feature in our extension, verified it in JupyterLab, and committed your changes
12
12
- Practiced one‑shot vs structured prompting, model selection, and context management; got comfortable reviewing, iterating on, and rolling back AI‑generated edits
13
13
- Gained confidence to continue exploring extension ideas primarily by prompting, while being able to understand and edit the generated code
14
-
::::
14
+
:::
15
15
16
16
:::{note} Inspired by...
17
17
:class: dropdown
@@ -50,6 +50,29 @@ You would never hire a developer and expect absolute perfection in their creativ
50
50
- Treat errors as learning opportunities for both you and the AI
51
51
- Don't be afraid to roll back to the beginning and start over if AI doubled down on a wrong path
52
52
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
+
53
76
### 🧠 Understanding {term}`LLMs <LLM>` (large language models)
54
77
55
78
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
205
228
-**LLM Options:**
206
229
- Built-in models (Claude Sonnet 4.5, GPT-5, Gemini 2.5 Pro and more) with Cursor subscription
207
230
-**Best for:** Developers who want a polished, GUI-driven experience
@@ -693,6 +716,13 @@ Before we dive into our structured approach, let's witness what modern AI can ac
693
716
694
717
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:
695
718
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
+
696
726
```
697
727
Extend this image viewer extension to add image editing capabilities:
698
728
@@ -733,6 +763,14 @@ When you give this prompt to an AI agent like Cursor or Claude Code, it will typ
733
763
734
764
Send the prompt and watch as it generates the entire feature. **In about 2-3 minutes**, you will have a fully functional image editor!
735
765
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
+
736
774
**Review the generated code**
737
775
- Cursor will suggest changes across multiple files
738
776
- Read through each change carefully
@@ -995,6 +1033,15 @@ As you work through phases, keep an eye on **context window percentage** (shown
995
1033
- ✅ Major refactoring complete
996
1034
:::
997
1035
1036
+
:::{dropdown} Add Jupyter docs to Cursor (recommended)
- 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
+
998
1045
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)
0 commit comments