Skip to content

Instantly share code, notes, and snippets.

@Abban
Last active May 4, 2026 09:25
Show Gist options
  • Select an option

  • Save Abban/718a92afa27c676f135c342101988e39 to your computer and use it in GitHub Desktop.

Select an option

Save Abban/718a92afa27c676f135c342101988e39 to your computer and use it in GitHub Desktop.
Check your NPM dependencies for Claude commits
#!/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 );
{
"scripts": {
"fuck-claude": "GITHUB_AUTH_TOKEN=$npm_config_github_auth_token bin/fuck-claude.js"
},
"devDependencies": {
"octokit": "^5.0.5",
}
}
@Abban

Abban commented Apr 29, 2026 •

Copy link
Copy Markdown
Author

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: Claude string. It might help you get a feeling for what dependencies are accepting low quality PRs.

  1. Add the script into a bin folder in your project.
  2. Run npm install -D octokit to install the GitHub js API library.
  3. Add the command in the scripts section of your package.json.
  4. Run it with $ npm run fuck-claude --github-auth-token=<YOUR PERSONAL ACCESS TOKEN>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment