What You’ll Learn
- How to upload a multi-file Python project into a sandbox to simulate a repository
- How to run a test suite before and after a fix to demonstrate a regression cycle
- How to apply a targeted code fix by reading, patching, and writing a file
- How to show a simple diff of the change inside the sandbox
Prerequisites
- Declaw running locally or in the cloud (see Deployment)
DECLAW_API_KEYandDECLAW_DOMAINset in your environment
This example is available in Python. TypeScript support coming soon.
Code Walkthrough
1. The buggy repository
The simulated repository contains two modules and a test file.string_utils.py has a deliberate bug — the count_vowels function is missing 'u' from the vowel set:
2. Upload and run tests before the fix
3. Apply the bug fix
The fix script reads the file, applies a targeted string replacement, and writes it back:4. Show the diff
5. Run tests after the fix
Expected Output
Extending to Real Git Repositories
The example simulates a repository by uploading files. To work with a real git repository, installgit first and then clone: