Last active
May 4, 2026 09:25
-
-
Save Abban/718a92afa27c676f135c342101988e39 to your computer and use it in GitHub Desktop.
Check your NPM dependencies for Claude commits
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
| #!/usr/bin/env node | |
| import fs from 'node:fs'; | |
| import { Octokit } from 'octokit'; | |
| const packages = fs.readdirSync( './node_modules', { withFileTypes: true } ).filter( x => x.isDirectory() && x.name[ 0 ] !== '@' ).map( x => x.name ); | |
| const octokit = new Octokit( { | |
| auth: `token ${ process.env.GITHUB_AUTH_TOKEN }`, | |
| } ); | |
| const errors = []; | |
| const claudes = []; | |
| const extractRepoDetailsFromURL = ( url ) => { | |
| return url | |
| .replace( 'git+ssh://git@github.com/', '' ) | |
| .replace( 'git@github.com:', '' ) | |
| .replace( 'github:', '' ) | |
| .replace( 'git+', '' ) | |
| .replace( '.git', '' ) | |
| .replace( 'git:', '' ) | |
| .replace( 'https:', '' ) | |
| .replace( 'http:', '' ) | |
| .replace( '//github.com/', '' ) | |
| .split( '/' ); | |
| } | |
| for ( const packageName of packages ) { | |
| const path = `./node_modules/${ packageName }/package.json`; | |
| if ( fs.existsSync( path ) ) { | |
| const data = JSON.parse( fs.readFileSync( path, 'utf8' ) ); | |
| const url = data.repository?.url ?? data.repository; | |
| if ( url.includes( 'gitlab' ) ) { | |
| continue; | |
| } | |
| const [ owner, repo ] = extractRepoDetailsFromURL( url ); | |
| try { | |
| let response = await octokit.request( 'GET /repos/{owner}/{repo}/commits', { | |
| owner, | |
| repo, | |
| per_page: 100, | |
| headers: { | |
| 'X-GitHub-Api-Version': '2026-03-10', | |
| }, | |
| } ); | |
| if ( response.data.filter( x => x.commit.message.includes( 'Co-authored-by: Claude' ) ).length > 0 ) { | |
| claudes.push( packageName ); | |
| } | |
| } catch ( e ) { | |
| errors.push( packageName ) | |
| } | |
| } | |
| } | |
| console.log( 'The following packages have accepted Claude contributions' ); | |
| console.log( '=========================================================' ); | |
| console.log( claudes ); | |
| console.log( '' ); | |
| console.log( 'Did not check these packages' ); | |
| console.log( '============================' ); | |
| console.log( errors ); |
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
| { | |
| "scripts": { | |
| "fuck-claude": "GITHUB_AUTH_TOKEN=$npm_config_github_auth_token bin/fuck-claude.js" | |
| }, | |
| "devDependencies": { | |
| "octokit": "^5.0.5", | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will look at all your NPM dependencies and ping the GitHub API for the latest 100 commits and check them for the
Co-authored-by: Claudestring. It might help you get a feeling for what dependencies are accepting low quality PRs.npm install -D octokitto install the GitHub js API library.package.json.$ npm run fuck-claude --github-auth-token=<YOUR PERSONAL ACCESS TOKEN>