Agent skill

Patch Anatomy

by Paresh-Maheshwari in Paresh-Maheshwari/morphe-ai

How to write Morphe patches — bytecodePatch DSL, compatibility, extensions, options, finalization.

GPL-3.0Auto-check passed

Install Patch Anatomy

skills CLI
$ npx skills add Paresh-Maheshwari/morphe-ai --skill patch-anatomy -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Paresh-Maheshwari/morphe-ai patch-anatomy --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Paresh-Maheshwari/morphe-ai.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.kiro/skills/patch-anatomy .claude/skills/patch-anatomy && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
patch-anatomy
GitHub stars
178
Token cost
~2.4k tokens
SKILL.md length
357 words
Files
1
Skills in repo
13
Repo updated
First seen
Licence
GPL-3.0

At a glance

How to write Morphe patches — bytecodePatch DSL, compatibility, extensions, options, finalization.

  • Creating new patches
  • SKILL.md covers Patch Types, Complete Patch Example, addInstructions — Deprecation… and Patch Options, plus 11 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Understanding patch structure

What it does

Patch Anatomy is an agent skill from Paresh-Maheshwari/morphe-ai. How to write Morphe patches — bytecodePatch DSL, compatibility, extensions, options, finalization. Use when creating new patches or understanding patch structure.

Its SKILL.md is about 2.4k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: Morphe's AI-powered Android APK patching workspace — multi-agent pipeline for APK analysis, target hunting, patch writing & deployment. The licence is GPL-3.0.

When your agent uses it

  • Creating new patches
  • Understanding patch structure

Example prompts

  • “/patch-anatomy”

What it can do on your machine

Read from SKILL.md and the folder at commit 2d7fde2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are kotlin and java).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Patch Anatomy loads about 2.4k tokens when it runs. Until then it costs about 44 tokens; SKILL.md has 357 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~44
When it runs · the whole SKILL.md, loaded when a task matches
~2.4k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Paresh-Maheshwari/morphe-ai at commit 2d7fde2, republished under its GPL-3.0 licence (© Paresh-Maheshwari). 357 words, ~2,391 tokens.

Download SKILL.mdSave it as .claude/skills/patch-anatomy/SKILL.md (or your agent's skills folder).
name
patch-anatomy
description
How to write Morphe patches — bytecodePatch DSL, compatibility, extensions, options, finalization. Use when creating new patches or understanding patch structure.

When to use: Writing patches — bytecodePatch DSL, compatibility declarations, extensions, options, finalization. Keep patches minimal — put complex logic in extensions.

Morphe Patch Anatomy — Official Reference

⚠️ Pinned source: morphe-patcher 6f189f9. Official docs may lag the source — the pinned source wins if anything contradicts this file.

Patch Types

TypeUse WhenPerformance
bytecodePatchModifying Dalvik bytecodeFast — no resource decoding
rawResourcePatchModifying raw files/assetsMedium
resourcePatchModifying decoded XMLSlow — decodes all resources

Always prefer bytecodePatch.

Complete Patch Example

kotlin
val COMPATIBILITY_XYZ = Compatibility(
    packageName = "app.xyz.mobile",
    name = "XYZ App",
    apkFileType = ApkFileType.XAPK,
    appIconColor = 0xFF3300,   // 0xRRGGBB — six-digit hex, zero alpha byte
    targets = listOf(
        AppTarget(version = "2.0.0"),
        AppTarget(version = "1.0.42"),
    )
)

@Suppress("unused")
val disableAdsPatch = bytecodePatch(
    name = "Disable ads",
    description = "Disables ads in the app.",
    default = true               // omit or set false for universal patches (enforced by builder)
) {
    compatibleWith(COMPATIBILITY_XYZ)
    dependsOn(disableAdsResourcePatch)
    extendWith("disable-ads.mpe")   // ← extension artifact is .mpe, not .mpp

    execute {
        showAdsFingerprint.method.addInstructions(0, """
            invoke-static {}, LDisableAdsPatch;->shouldDisableAds()Z
            move-result v0
            return v0
        """)
    }

    finalize {
        // Post-processing after all dependent patches execute
    }
}

addInstructions — Deprecation Note

addInstructions(String) (no-index form) is deprecated. Always supply the index:

kotlin
// ✅ Current
method.addInstructions(0, "const/4 v0, 0x1\nreturn v0")

// ❌ Deprecated — will be deleted
method.addInstructions("const/4 v0, 0x1\nreturn v0")

Patch Options

kotlin
val patch = bytecodePatch(name = "Configurable") {
    val value by stringOption(name = "Color")
    val custom by option<String>(name = "Custom option")
    execute { println(value) }
}

Options can be shared across patches:

kotlin
val sharedOption = stringOption(name = "Shared")
bytecodePatch(name = "A") { val v by sharedOption() }
bytecodePatch(name = "B") { val v by sharedOption() }

Extensions (Runtime DEX Code)

Extensions are precompiled DEX files (.mpe) merged into the patched app before patch execution.

java
public class ComplexPatch {
    public static void doSomething() { /* complex logic */ }
}

Referenced in patches:

kotlin
val patch = bytecodePatch(name = "Complex") {
    extendWith("complex-patch.mpe")   // ← .mpe not .mpp
    execute {
        fingerprint.method.addInstructions(0, "invoke-static {}, LComplexPatch;->doSomething()V")
    }
}
extendWithAll — variable extension count

When the set of extensions is not known until patch time (e.g., determined by a dependency):

kotlin
extendWithAll(Supplier { listOf(stream1, stream2) })

Finalization Order

kotlin
val patch = bytecodePatch(name = "Main") {
    dependsOn(bytecodePatch(name = "Dep") {
        execute { print("1") }
        finalize { print("4") }
    })
    execute { print("2") }
    finalize { print("3") }
}
// Output: 1234 (execute in dependency order, finalize in reverse)

Compatibility Declaration

kotlin
val COMPAT = Compatibility(
    packageName = "com.example.app",  // must match Android package name regex
    name = "App Name",                // required when packageName is non-null, must be non-blank
    description = "Optional description.",
    apkFileType = ApkFileType.XAPK,   // see ApkFileType below
    appIconColor = 0x6200EE,          // 0xRRGGBB — alpha byte MUST be 0x00
    signatures = setOf(
        "a1b2c3...64hexchars"         // SHA-256 from apksigner verify --print-certs, 64 hex chars
    ),
    targets = listOf(                 // must be non-empty; newest first
        AppTarget(version = "2.0.0", minSdk = 28, isExperimental = true),
        AppTarget(version = "1.0.0", minSdk = 26),
    )
)
Rules
  • packageName + name go together — if packageName is set, name must also be non-blank.
  • appIconColor is 0xRRGGBB (six-digit). The alpha byte must be 0x00 (zero) or the constructor throws. E.g. 0x6200EE ✅, 0xFF6200EE ❌.
  • signatures — each string must be exactly 64 hex characters (SHA-256).
  • targets — must be non-empty. Use AppTarget(version = null) for "any version".
  • Duplicate versions in targets throw IllegalArgumentException.
including / excluding
kotlin
val COMPAT_PLUS = COMPAT.including(AppTarget(version = "3.0.0"))
val COMPAT_MINUS = COMPAT.excluding("1.0.0", "1.0.42")

ApkFileType Values

kotlin
enum class ApkFileType {
    APK,           // single APK (recommended)
    APK_REQUIRED,  // single APK (required — other formats rejected)
    APKM,          // APKMirror bundle (recommended)
    APKM_REQUIRED, // APKMirror bundle (required)
    APKS,          // bundletool APKS (recommended)
    APKS_REQUIRED, // bundletool APKS (required)
    XAPK,          // APKPure XAPK (recommended)
    XAPK_REQUIRED, // APKPure XAPK (required)
}

Non-_REQUIRED variants are recommendations; _REQUIRED variants enforce the format.

Show full SKILL.md (144 more words)Show less

AppTarget

kotlin
data class AppTarget(
    val version: String?,                         // null = any version
    val versionCodes: Map<SupportedAbi, Int>? = null,
    val isExperimental: Boolean = false,
    val minSdk: Int? = null,
    val description: String? = null,
)

enum class SupportedAbi { ARM64_V8A, ARMEABI_V7A, X86_64, X86 }

versionCodes is only needed for apps that ship multiple releases per user-visible version (e.g., Meta apps). Pass a single Int overload to use the same code for all ABIs:

kotlin
AppTarget(version = "2.0.0", versionCode = 20000)
// expands to Map<SupportedAbi, Int> for all entries

Patch Availability API

Declare how a patch behaves for a given install target (Manager / CLI evaluates before selection):

kotlin
import app.morphe.patcher.patch.InstallerType      // STANDARD, MOUNT, SHIZUKU
import app.morphe.patcher.patch.ApkArchitecture    // ARM64_V8A, ARMEABI_V7A, X86_64, X86, UNIVERSAL
import app.morphe.patcher.patch.PatchAvailability  // ENABLED, DISABLED, REQUIRED, UNAVAILABLE
import app.morphe.patcher.patch.AvailabilityResolver

val patch = bytecodePatch(name = "Root Only Feature") {
    availability { installer, arch ->
        if (installer == InstallerType.MOUNT) PatchAvailability.ENABLED
        else PatchAvailability.UNAVAILABLE
    }
    execute { /* … */ }
}

Patches without an availability block fall back to their default flag.

category

Optional free-form group for UI display:

kotlin
val patch = bytecodePatch(name = "Remove Banner Ads") {
    category("Ads")
    execute { /* … */ }
}

default Flag Warning

Universal patches (no compatibleWith) with default = true are overridden to false with a console warning at build time. Always set default = false for universal patches.

Project Structure

patches/src/main/kotlin/app/<group>/patches/
├── shared/              # Shared across all apps
├── <app>/
│   ├── shared/Constants.kt
│   └── <category>/
│       ├── Fingerprints.kt
│       └── SomePatch.kt
extensions/<name>/src/main/java/   # Extension code (produces .mpe)

Conventions

  • Name patches after what they do: "Disable ads", "Remove watermark"
  • Description in third person, present tense, ending with period
  • Name fingerprints with best guess of target method purpose
  • Keep patches minimal — put complex logic in extensions
  • Add @Suppress("unused") on top-level patch vals
  • Document non-obvious code

Key Imports

kotlin
import app.morphe.patcher.Fingerprint
import app.morphe.patcher.string
import app.morphe.patcher.methodCall
import app.morphe.patcher.fieldAccess
import app.morphe.patcher.newInstance
import app.morphe.patcher.instanceOf
import app.morphe.patcher.checkCast
import app.morphe.patcher.opcode
import app.morphe.patcher.literal
import app.morphe.patcher.resourceLiteral
import app.morphe.patcher.anyInstruction
import app.morphe.patcher.extensions.InstructionExtensions.addInstruction
import app.morphe.patcher.extensions.InstructionExtensions.addInstructions
import app.morphe.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.morphe.patcher.extensions.InstructionExtensions.getInstruction
import app.morphe.patcher.patch.bytecodePatch
import app.morphe.patcher.patch.rawResourcePatch
import app.morphe.patcher.patch.resourcePatch
import app.morphe.patcher.patch.ApkFileType
import app.morphe.patcher.patch.AppTarget
import app.morphe.patcher.patch.Compatibility
import app.morphe.patcher.patch.InstallerType
import app.morphe.patcher.patch.ApkArchitecture
import app.morphe.patcher.patch.PatchAvailability
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.Opcode
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction

© Paresh-Maheshwari, GPL-3.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .kiro/skills/patch-anatomy of Paresh-Maheshwari/morphe-ai.

Open the folder on GitHubat commit 2d7fde2

Compare with similar skills

Patch Anatomy next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Patch Anatomy compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Patch Anatomy this skillParesh-Maheshwari/morphe-ai178—~2.4kAutomated safety check: PassGPL-3.0
Optionsasgeirtj/system_prompts_leaks69k—~918Automated safety check: PassCC0-1.0
Browser Extension Buildersickn33/agentic-awesome-skills47k2 repos~2.3kAutomated safety check: PassMIT
Browser Extension Launchsickn33/agentic-awesome-skills47k1 repos~1.4kAutomated safety check: PassMIT
Browser Extension Reversesickn33/agentic-awesome-skills47k1 repos~695Automated safety check: PassMIT
Browser Extension Reversezhaoxuya520/reverse-skill41k2 repos~366Automated safety check: PassMIT

Similar skills

  • Options

    asgeirtj/system_prompts_leaks

    Present multiple design options as a vertical stack of anchored turns

    69k GitHub stars~918 tokensUpdated today
    Auto-check passed
  • Browser Extension Builder

    sickn33/agentic-awesome-skills

    Expert in building browser extensions that solve real problems - Chrome, Firefox, and cross-browser extensions.

    47k GitHub starsUsed in 2 repos~2.3k tokens
    DevelopmentAuto-check passed
  • Browser Extension Launch

    sickn33/agentic-awesome-skills

    Builds, tests, packages, and prepares Chrome extensions for store launch from a plain-language idea; use for new extensions, fixes, releases, and submission recovery.

    47k GitHub starsUsed in 1 repo~1.4k tokens
    DevelopmentAuto-check passed
  • Browser Extension Reverse

    sickn33/agentic-awesome-skills

    Authorized reverse engineering of Chrome/Firefox extensions: manifest analysis, background workers, content scripts, and extension-based credential or data-exposure research.

    47k GitHub starsUsed in 1 repo~695 tokens
    SecurityAuto-check passed
  • Browser Extension Reverse

    zhaoxuya520/reverse-skill

    A skill your agent uses for authorized reverse engineering of browser extensions (Chrome/Firefox) including manifest analysis, background workers, and extension-based credential or traffic logic…

    41k GitHub starsUsed in 2 repos~366 tokens
    SecurityAuto-check passed
  • Browser Extension Builder

    davila7/claude-code-templates

    Expert in building browser extensions that solve real problems - Chrome, Firefox, and cross-browser extensions.

    33k GitHub starsUsed in 5 repos~1.5k tokens
    DevelopmentAuto-check passed

More from Paresh-Maheshwari/morphe-ai

All 13 skills in this repo
  • Build Deploy Troubleshoot

    Paresh-Maheshwari/morphe-ai

    Build, test, deploy, and troubleshoot Morphe patches — gradle commands, CLI usage, git workflow, common errors and fixes.

    178 GitHub stars~1.1k tokensUpdated 11 days ago
    Auto-check passed
  • Dev Environment Setup

    Paresh-Maheshwari/morphe-ai

    Complete Morphe development environment setup — prerequisites, cloning repos, gradle auth, IDE config, build commands.

    178 GitHub stars~1k tokensUpdated 11 days ago
    Auto-check: notes
  • Fingerprinting Guide

    Paresh-Maheshwari/morphe-ai

    Complete guide to Morphe fingerprinting — how to identify obfuscated methods using stable characteristics.

    178 GitHub stars~2.4k tokensUpdated 11 days ago
    Auto-check passed
  • Morphe CLI Reference

    Paresh-Maheshwari/morphe-ai

    Morphe CLI v1.17.0 (morphe-desktop) complete command reference — patch, list-patches, list-versions, options-create, utility install/uninstall.

    178 GitHub stars~2.9k tokensUpdated 11 days ago
    Auto-check passed
  • Morphe Faq And App Notes

    Paresh-Maheshwari/morphe-ai

    Morphe FAQ, current pinned official app targets, and app-specific notes.

    178 GitHub stars~573 tokensUpdated 11 days ago
    Auto-check passed
  • Morphe Library Reference

    Paresh-Maheshwari/morphe-ai

    Complete reference for all Morphe utility libraries — BytecodeUtils, ResourceUtils, FreeRegisterProvider, Settings, UI, Extensions.

    178 GitHub stars~1.9k tokensUpdated 11 days ago
    Auto-check passed

Questions about Patch Anatomy

What does Patch Anatomy do?

How to write Morphe patches — bytecodePatch DSL, compatibility, extensions, options, finalization. Patch Anatomy is an agent skill from Paresh-Maheshwari/morphe-ai. How to write Morphe patches — bytecodePatch DSL, compatibility, extensions, options, finalization.

When should I use Patch Anatomy?

Patch Anatomy fits situations like: creating new patches; understanding patch structure.

How do I install Patch Anatomy in Claude Code?

Run `npx skills add Paresh-Maheshwari/morphe-ai --skill patch-anatomy -a claude-code`. Or copy the skill folder (.kiro/skills/patch-anatomy in Paresh-Maheshwari/morphe-ai) into .claude/skills/patch-anatomy in your project. Claude Code loads it when a task matches its description.

How do I install Patch Anatomy in Codex?

Run `npx skills add Paresh-Maheshwari/morphe-ai --skill patch-anatomy -a codex`. Or copy the skill folder (.kiro/skills/patch-anatomy in Paresh-Maheshwari/morphe-ai) into .agents/skills/patch-anatomy in your project. Codex loads it when a task matches its description.

Can I use Patch Anatomy in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Paresh-Maheshwari/morphe-ai --skill patch-anatomy -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/patch-anatomy, .gemini/skills/patch-anatomy, .github/skills/patch-anatomy and .opencode/skills/patch-anatomy in your project.

What does Patch Anatomy need to run?

SKILL.md names no scripts, command-line tools or credentials: Patch Anatomy is instructions for the agent only.

Does Patch Anatomy access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Patch Anatomy safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Patch Anatomy use?

Patch Anatomy is published under the GPL-3.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Patch Anatomy use?

About 2.4k tokens (SKILL.md is roughly 9.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Patch Anatomy?

Skills that share tags, products or a category with Patch Anatomy: Options (asgeirtj/system_prompts_leaks, 69k stars), Browser Extension Builder (sickn33/agentic-awesome-skills, 47k stars), Browser Extension Launch (sickn33/agentic-awesome-skills, 47k stars) and Browser Extension Reverse (sickn33/agentic-awesome-skills, 47k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Patch Anatomy?

Paresh-Maheshwari (a GitHub user) maintains it in Paresh-Maheshwari/morphe-ai, which has 178 GitHub stars. The repository holds 13 skills in this directory. The repository was last updated on September 29, 2026.

Source: Paresh-Maheshwari/morphe-ai on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.