When adding or changing API-like functions (parsers, clients, helpers), treat them as having a stable contract: define the accepted inputs and exact output shape, cover tricky edge cases with regression tests, and remove/deprecate superseded code paths so the API surface stays unambiguous.
How to apply:
Example (contract + regression):
// Contract: treat GitHub URLs as { url } and local/UNC paths as { path }
function getCodebaseInput(input: string): { url?: string; path?: string } {
// ...implementation
return {};
}
// Regression cases for gaps
test('treats relative paths as paths', () => {
expect(getCodebaseInput('../repo')).toEqual({ path: '../repo' });
});
test('treats UNC paths as paths', () => {
expect(getCodebaseInput('\\server\\share\\repo')).toEqual({
path: '\\server\\share\\repo',
});
});
Checklist:
Enter the URL of a public GitHub repository