We present CodeGenie, a tool that implements a test-driven approach to search and reuse of code available on largescale code repositories. With CodeGenie, developers design test cases for a desired feature first, similar to Test-driven Development (TDD). However, instead of implementing the feature from scratch, CodeGenie automatically searches for an existing implementation based on information available in the tests. To check the suitability of the candidate results in the local context, each result is automatically woven into the developer’s project and tested using the original tests. The developer can then reuse the most suitable result. Later, reused code can also be unwoven from the project as wished. For the code searching and wrapping facilities, CodeGenie relies on Sourcerer, an Internet-scale source code infrastructure that we have developed. Categories and Subject Descriptors D.2.13 [Software Engineering]: Reusable Software; D.2.2 [Software Engineering]: Coding Tools an...