From 3b34ff5eee33cde9870b0302d31d4213a9d3d033 Mon Sep 17 00:00:00 2001 From: Stephen Gruppetta Date: Fri, 8 May 2026 20:33:59 +0000 Subject: [PATCH 1/5] Sample code for: Cursor vs Windsurf: Which AI Code Editor Is Best for Python? --- cursor-vs-windsurf-python/README.md | 3 + .../cursor/http-client-conventions.mdc | 11 +++ cursor-vs-windsurf-python/prompts.md | 72 +++++++++++++++++++ .../windsurf/http-client-conventions.md | 10 +++ 4 files changed, 96 insertions(+) create mode 100644 cursor-vs-windsurf-python/README.md create mode 100644 cursor-vs-windsurf-python/cursor/http-client-conventions.mdc create mode 100644 cursor-vs-windsurf-python/prompts.md create mode 100644 cursor-vs-windsurf-python/windsurf/http-client-conventions.md diff --git a/cursor-vs-windsurf-python/README.md b/cursor-vs-windsurf-python/README.md new file mode 100644 index 0000000000..ace27f3932 --- /dev/null +++ b/cursor-vs-windsurf-python/README.md @@ -0,0 +1,3 @@ +# Cursor vs Windsurf: Which AI Code Editor Is Best for Python? + +This folder provides the code examples for the Real Python tutorial [Cursor vs Windsurf: Which AI Code Editor Is Best for Python?](https://realpython.com/cursor-vs-windsurf-python/) diff --git a/cursor-vs-windsurf-python/cursor/http-client-conventions.mdc b/cursor-vs-windsurf-python/cursor/http-client-conventions.mdc new file mode 100644 index 0000000000..9051badcfb --- /dev/null +++ b/cursor-vs-windsurf-python/cursor/http-client-conventions.mdc @@ -0,0 +1,11 @@ +--- +globs: "**/*.py" +alwaysApply: false +--- +# Instructions +- Use type hints for all functions, return values, and dataclass fields +- Use `httpx.AsyncClient` for HTTP requests; do not use `requests` + or `aiohttp` +- Use `await asyncio.sleep()` for delays; do not use `time.sleep()` +- Return dataclasses for HTTP responses, not raw dictionaries +- Follow PEP 8 style conventions diff --git a/cursor-vs-windsurf-python/prompts.md b/cursor-vs-windsurf-python/prompts.md new file mode 100644 index 0000000000..0d0d9adaf1 --- /dev/null +++ b/cursor-vs-windsurf-python/prompts.md @@ -0,0 +1,72 @@ +# Prompts + +Copy-paste these into Cursor and Windsurf in order while following the tutorial. + +## 1. Set up the project + +``` +Set up a Python project in this directory following standard Python +packaging conventions: +- Create a virtual environment +- Install httpx==0.28.1 and pytest==9.0.2 +- Add a tests/ directory +- Use the directory name as the package name +- Only include the dependencies explicitly listed here +``` + +## 2. Write the async fetch function + +``` +Create a file called `fetcher.py` and write an async function +called fetch_json that: +- Takes a URL string and an optional integer max_retries (default 3) +- Uses httpx.AsyncClient to fetch JSON from the URL +- Retries up to max_retries times with exponential backoff (1s, 2s, 4s) + on any httpx.HTTPError +- Returns the JSON response as a typed dataclass called FetchResult + with fields: url (str), status_code (int), and data (dict) +- Uses proper type hints throughout +``` + +## 3. Generate tests + +Before sending this prompt, open `fetcher.py` and replace +`await asyncio.sleep(delay)` with `time.sleep(delay)`, then add +`import time` at the top. Save the file. + +``` +Create tests/test_fetcher.py with pytest tests for fetch_json that: +- Test successful fetch returns correct FetchResult +- Test fetch retries twice then succeeds +- Test fetch raises after exhausting retries +- Test two concurrent fetches complete in <4s + (one with 1s+2s retry delays, one instant) +- Test fetch can be cancelled during retry delay +Use httpx.MockTransport for mocking. +``` + +## 4. Plan-mode prompt + +Switch each editor to its Plan mode before sending: + +``` +Add a retry_budget parameter to fetch_json that limits the total +cumulative wait time across all retries. +``` + +## 5. Autocomplete starter snippet + +Type this into a file and let each editor complete it: + +```python +@dataclass +class RetryMetadata: + attempts_made: +# ... +``` + +## 6. Manual review (Windsurf Ask mode) + +``` +Review fetcher.py for bugs and lint issues and summarize what you find. +``` diff --git a/cursor-vs-windsurf-python/windsurf/http-client-conventions.md b/cursor-vs-windsurf-python/windsurf/http-client-conventions.md new file mode 100644 index 0000000000..7d64b101f3 --- /dev/null +++ b/cursor-vs-windsurf-python/windsurf/http-client-conventions.md @@ -0,0 +1,10 @@ +--- +trigger: glob +globs: "**/*.py" +--- +# Instructions +- Use type hints for all functions, return values, and dataclass fields +- Use `httpx.AsyncClient` for HTTP requests; do not use `requests` or `aiohttp` +- Use `await asyncio.sleep()` for delays; do not use `time.sleep()` +- Return dataclasses for HTTP responses, not raw dictionaries +- Follow PEP 8 style conventions From 39b8465a416e496f219429864eee9be71ad7ce9e Mon Sep 17 00:00:00 2001 From: stephengruppetta <51741022+stephengruppetta@users.noreply.github.com> Date: Fri, 8 May 2026 21:36:34 +0100 Subject: [PATCH 2/5] Update README to clarify content description --- cursor-vs-windsurf-python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cursor-vs-windsurf-python/README.md b/cursor-vs-windsurf-python/README.md index ace27f3932..7dbf0d5207 100644 --- a/cursor-vs-windsurf-python/README.md +++ b/cursor-vs-windsurf-python/README.md @@ -1,3 +1,3 @@ # Cursor vs Windsurf: Which AI Code Editor Is Best for Python? -This folder provides the code examples for the Real Python tutorial [Cursor vs Windsurf: Which AI Code Editor Is Best for Python?](https://realpython.com/cursor-vs-windsurf-python/) +This folder provides the prompts used in the Real Python tutorial [Cursor vs Windsurf: Which AI Code Editor Is Best for Python?](https://realpython.com/cursor-vs-windsurf-python/) From 36d239df2b0b571274d63037fe69c5f47c6a9663 Mon Sep 17 00:00:00 2001 From: stephengruppetta <51741022+stephengruppetta@users.noreply.github.com> Date: Fri, 8 May 2026 21:40:53 +0100 Subject: [PATCH 3/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- cursor-vs-windsurf-python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cursor-vs-windsurf-python/README.md b/cursor-vs-windsurf-python/README.md index 7dbf0d5207..b45c0a4279 100644 --- a/cursor-vs-windsurf-python/README.md +++ b/cursor-vs-windsurf-python/README.md @@ -1,3 +1,3 @@ # Cursor vs Windsurf: Which AI Code Editor Is Best for Python? -This folder provides the prompts used in the Real Python tutorial [Cursor vs Windsurf: Which AI Code Editor Is Best for Python?](https://realpython.com/cursor-vs-windsurf-python/) +This folder provides the prompts and Cursor/Windsurf rules files used in the Real Python tutorial [Cursor vs Windsurf: Which AI Code Editor Is Best for Python?](https://realpython.com/cursor-vs-windsurf-python/) From 51850ff1983c6964fff214bdcd1f373427db9a9c Mon Sep 17 00:00:00 2001 From: stephengruppetta <51741022+stephengruppetta@users.noreply.github.com> Date: Fri, 8 May 2026 21:45:15 +0100 Subject: [PATCH 4/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- cursor-vs-windsurf-python/prompts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cursor-vs-windsurf-python/prompts.md b/cursor-vs-windsurf-python/prompts.md index 0d0d9adaf1..3fb84c4814 100644 --- a/cursor-vs-windsurf-python/prompts.md +++ b/cursor-vs-windsurf-python/prompts.md @@ -61,7 +61,7 @@ Type this into a file and let each editor complete it: ```python @dataclass class RetryMetadata: - attempts_made: + attempts_made: int # ... ``` From 43f73a303cac6bd2ae9dfec902de1aa79e8a6791 Mon Sep 17 00:00:00 2001 From: stephengruppetta <51741022+stephengruppetta@users.noreply.github.com> Date: Fri, 8 May 2026 21:45:27 +0100 Subject: [PATCH 5/5] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- cursor-vs-windsurf-python/prompts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cursor-vs-windsurf-python/prompts.md b/cursor-vs-windsurf-python/prompts.md index 3fb84c4814..e89ca1d639 100644 --- a/cursor-vs-windsurf-python/prompts.md +++ b/cursor-vs-windsurf-python/prompts.md @@ -24,7 +24,7 @@ called fetch_json that: - Retries up to max_retries times with exponential backoff (1s, 2s, 4s) on any httpx.HTTPError - Returns the JSON response as a typed dataclass called FetchResult - with fields: url (str), status_code (int), and data (dict) + with fields: url (str), status_code (int), and data (dict[str, Any]) - Uses proper type hints throughout ```