We present CodeGenie, a tool that implements a test-driven approach to search and reuse of code available on large-scale code repositories. While using CodeGenie developers design test cases for a desired feature first, similar to Test-driven Development (TDD). However, instead of implementing the feature as in TDD, CodeGenie automatically searches for it 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.3 [Software Engineering]: Coding Tools and Techniques General...