Skip to content

Distill generic patterns from work code and push to your personal GitHub

License

Notifications You must be signed in to change notification settings

smartvain/codedistill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codedistill (cdst)

日本語

Distill generic patterns from work code and push to your personal GitHub.

Work code contains company-specific naming, business logic, and credentials — but the underlying programming patterns are yours. cdst uses Claude Code to generalize your code and push it to a personal repository with one command.

How it works

cdst push src/services/acme-payment-api.ts
  1. Reads the source file
  2. Claude Code generalizes the code (removes company names, credentials, business logic)
  3. Shows you the result for review
  4. Pushes to your personal GitHub repository via the Contents API

Before (work code):

import { AcmeAuthClient } from "../auth/acme-auth";

export async function callPaymentAPI(orderId: string, amount: number) {
  const auth = new AcmeAuthClient(process.env.ACME_SECRET_KEY!);
  // ... company-specific implementation
}

After (generalized):

/**
 * Fetch wrapper with retry and exponential backoff.
 */
export async function fetchWithRetry(
  url: string,
  options: RequestInit & { maxRetries?: number }
): Promise<Response> {
  // ... generic pattern
}

Prerequisites

Setup

# Install
pnpm install
pnpm build
pnpm link --global

# Configure
cdst init

Usage

# Preview generalized code without pushing
cdst preview <file>

# Generalize and push to your personal repo
cdst push <file>

# Push with custom commit message
cdst push <file> -m "Add retry utility"

# Push to a custom path in the repo
cdst push <file> --path "libraries/http"

# Re-push a previously pushed file
cdst push <file> --force

# View configuration
cdst config --list

# Update a config value
cdst config defaultTargetPath libraries

Configuration

Stored at ~/.codedistill/config.json:

Key Description Default
githubToken GitHub Personal Access Token
githubRepo Target repo (owner/repo)
defaultBranch Branch to push to main
defaultTargetPath Base path in repo snippets

How code is organized in your repo

your-repo/
└── snippets/
    ├── patterns/
    │   └── retry-with-backoff.ts
    ├── utils/
    │   └── deep-merge.ts
    ├── middleware/
    │   └── jwt-auth-middleware.ts
    └── hooks/
        └── use-debounced-search.ts

Categories are suggested by AI: patterns, utils, data-structures, algorithms, api-integration, middleware, hooks, components, testing, config, other.

License

MIT

About

Distill generic patterns from work code and push to your personal GitHub

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •