-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Sample code for: Cursor vs Windsurf: Which AI Code Editor Is Best for Python? #766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3b34ff5
Sample code for: Cursor vs Windsurf: Which AI Code Editor Is Best for…
39b8465
Update README to clarify content description
stephengruppetta 36d239d
Potential fix for pull request finding
stephengruppetta 51850ff
Potential fix for pull request finding
stephengruppetta 43f73a3
Potential fix for pull request finding
stephengruppetta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +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/) | ||
11 changes: 11 additions & 0 deletions
11
cursor-vs-windsurf-python/cursor/http-client-conventions.mdc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
|
stephengruppetta marked this conversation as resolved.
Outdated
|
||
| - 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: | ||
|
stephengruppetta marked this conversation as resolved.
Outdated
|
||
| # ... | ||
| ``` | ||
|
|
||
| ## 6. Manual review (Windsurf Ask mode) | ||
|
|
||
| ``` | ||
| Review fetcher.py for bugs and lint issues and summarize what you find. | ||
| ``` | ||
10 changes: 10 additions & 0 deletions
10
cursor-vs-windsurf-python/windsurf/http-client-conventions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.