---
name: frankenstein-code
description: Find open-source code that already solves part of a goal (new build, refactor or fix), vet it, take only the needed pieces, and stitch them in with provenance recorded.
license: MIT
compatibility: Needs web and GitHub search. Uses parallel subagents when the agent supports them.
metadata:
  author: AjeyDS
  version: '1.0'
title: frankenstein-code
canonical_url: https://skilld.dev/gh/ajeyds/skills/frankenstein-code
last_updated: 2026-10-20T23:30:52.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install ajeyds/skills/frankenstein-code`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/frankenstein-code`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/ajeyds/skills/frankenstein-code) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/frankenstein-code`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/frankenstein-code --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/frankenstein-code --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Frankenstein Code

Goal: before writing something from scratch, find open-source pieces that already do part of the job, pick the best one for each part, take only what is needed, and stitch it into the project cleanly.

Use when the user invokes this skill, or asks things like "is there something open-source for this", "don't reinvent this", "find a library that does X", while building, refactoring or fixing.

Difference from `freshness-check`: that one checks a plan for newer tools and ideas. This one sources actual code and transplants it. Each skill works on its own; when both are used, run freshness-check first and this skill reuses its finds (see Step 2).

## Step 1. Pin the goal and break it into parts

- Write the goal in one line: what we are building or fixing, and what "done" looks like.
- Note constraints: language, framework, runtime, commercial or not (affects license), size limits.
- If the project is reachable, read it first: language, existing dependencies, patterns, how errors and logging are done.
- Split the goal into a parts list. Each part is one job, described as a job, not a product. Example: "turn a PDF into text with layout kept", not "PDF library".
- Some parts are the core of the product. Mark them. Those usually stay our own code.
- Ask at most one question if the goal is unclear.

## Step 2. Search each part

**If a freshness-check brief exists in this conversation, start from it.** Take the tools, libraries and repos it named, map each to a part, and vet those first in Step 3. Only search further for parts the brief did not cover, or where its candidates fail vetting. Do not repeat searches it already did. If there is no brief, do the full search below.

Search per part, in parallel (one cheap subagent per part if available). Each returns at most 3 candidates.

Where to look:
- Package registries (npm, PyPI, crates.io, Go packages): best when the piece can be installed.
- GitHub repo search: filter by language, topic, stars and recent push date. Also check "awesome-<topic>" lists.
- GitHub code search: for a single function or algorithm, the smallest piece we could lift.
- Hugging Face and Papers with Code: for ML models and methods.
- Practitioner posts (Hacker News, Reddit, dev blogs): to see what people actually use and regret.
- For a bug fix: search the issue trackers of our dependencies for the error message first.

Query tips: phrase it as the problem ("diff two json documents"), try "alternative to <known tool>", add the language name.

## Step 3. Vet every candidate

Read the README and the actual code. Never trust a name or a search snippet.

| Check | Pass | Flag |
|---|---|---|
| License | MIT, Apache 2.0, BSD, ISC | GPL, AGPL, SSPL, no license (do not copy into a closed project) |
| Health | commits in the last ~6 months, releases, issues answered | archived, single abandoned maintainer |
| Fit | same language, API shape close to what we need | needs a big framework we don't use |
| Weight | small dependency tree | pulls in many heavy deps for one function |
| Safety | no open advisories (osv.dev, deps.dev), package name matches the real repo | look-alike names, very low downloads, install scripts |

Also confirm the functions we plan to use actually exist in the current version.

## Step 4. Choose how to take it (cheapest first)

1. **Install as a dependency.** Default when the project is healthy and we use a good share of it.
2. **Install but use only a submodule.** When the library is modular.
3. **Extract only the needed files (vendor).** When the library is huge, abandoned, or we must change its internals.
4. **Write our own, using it as a reference.** When the license blocks reuse or the piece is tiny. Learn the approach from docs or papers; do not rewrite copyleft code line by line.
5. **Build it ourselves.** When nothing fits, or the glue would be bigger than the piece.

Pause and get the user's OK before adding dependencies or vendoring code.

## Step 5. Extract (option 3 only)

- Shallow-clone into a temp folder and note the commit SHA.
- Start from the entry function we need and follow its imports. Keep only what is actually reached.
- Copy those files into `third_party/<name>/`.
- Keep the LICENSE file and copyright headers.
- Delete unused functions, files, config and tests for removed parts.
- Swap their heavy dependencies for ones we already have, where easy.
- Run their relevant tests, or write one small test, before changing anything.
- Delete the temp clone.

## Step 6. Stitch it in

- Put each piece behind our own small interface (an adapter). The rest of the code calls our interface, never the third-party code directly, so the piece can be swapped later.
- Convert data shapes, errors and logging at that boundary. Don't rewrite the insides unless needed.
- Add tests at the boundary.
- Record provenance in `THIRD_PARTY.md`: name, URL, commit or version, license, what was taken, what was changed.

## Step 7. Report

Keep it short. For each part:

- Pick and why (one line)
- How taken: install / submodule / extract / reference / build
- License
- Risks or open questions

List parts with no good match as "build ourselves". End with the proposed next step and wait for approval if anything gets installed or vendored.

## Rules

- Never copy copyleft code into a project that isn't released under a compatible license.
- Never vendor code without its license file.
- Fewer, healthier parts beat many small ones.
- If the glue is bigger than the piece, write the piece ourselves.
- Core product logic stays ours; reuse is for the plumbing around it.
