# Human-Readable Code Refactorer (`bread-kim/human-readable-code-refactorer`) Actor

Refactor JavaScript and TypeScript projects into cleaner, easier-to-maintain code. Improve formatting, names, JSX/CSS selectors, and structure, with static verification, patch replay, a cleaned project ZIP, before/after reports, and future coding rules.

- **URL**: https://apify.com/bread-kim/human-readable-code-refactorer.md
- **Developed by:** [bread kim](https://apify.com/bread-kim) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $200.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Human-Readable Code Refactorer

Turns an authorized JavaScript/TypeScript/React/HTML/CSS project into an actually modified, reviewable project package. It combines project-aware formatting, TypeScript symbol renames, synchronized HTML/JSX/CSS selector renames, bounded structural cleanup, atomic rollback, verification evidence, and patch replay.

### What you receive

- cleaned project ZIP
- combined, formatting, semantic, and optional proven-bug patches
- file-by-file before/after HTML
- naming and selector maps
- baseline and final verification reports
- protected/skipped/rolled-back changes
- project-tailored AGENTS, Codex, Cursor, and convention rules

### Modes

- **SAFE:** formatting and bounded non-contract local renames.
- **STANDARD:** SAFE plus cross-file internal symbols, proven selector references, CSS Modules, and shallow nesting cleanup.
- **DEEP:** STANDARD plus bounded pure extraction and duplication cleanup.
- Bug fixes are separate, opt-in, and require explicit behavior-change approval plus regression evidence.

### Source and privacy

Use a public GitHub repository or public HTTPS ZIP that you are authorized to process. Public GitHub refs are resolved to an immutable commit. Archives are bounded and reject traversal, links, collisions, secret-like paths, and private keys.

Core deterministic cleanup works without an AI API key. The optional customer-BYOK semantic provider is implemented but not live-verified and is off by default. Personal Codex authentication and seller credentials are never used by the Actor.

### Verification truth

V1 supports `STATIC_ONLY` only. It validates parsing, symbols, selector references, protected public contracts, patch replay, package integrity, and rerun stability. It does not execute customer tests, typecheck, build, lint, lifecycle scripts, arbitrary shell, or runtime UI checks; those are reported as `NOT_RUN`. Customers should run their own project checks after applying the patch. No formal behavior guarantee is claimed.

Legacy `ISOLATED_PROJECT_COMMANDS` requests fail with `UNSUPPORTED_EXECUTION_POLICY`; they are never silently downgraded.

See REQUIREMENTS.md, ARCHITECTURE.md, and SECURITY_REVIEW.md.

# Actor input Schema

## `source` (type: `object`):

JSON source contract. The prefill is a deterministic in-memory QA project; customer runs may use supported public repository or ZIP inputs.

## `mode` (type: `string`):

SAFE limits changes; STANDARD adds proven selector and shallow structure changes; DEEP adds bounded extraction and deduplication.

## `operation` (type: `string`):

ANALYZE reports only; APPLY produces modified source and patches.

## `behaviorChange` (type: `boolean`):

Must be true only for separately proven bug fixes.

## `bugFixPolicy` (type: `string`):

PROVEN_BUGS additionally requires behaviorChange and regression evidence.

## `cleanup` (type: `object`):

JSON booleans for formatting, names, selectors, structure, comments, duplication, and future rules.

## `style` (type: `object`):

JSON project-first style profile, formatting overrides, CSS convention, and report language.

## `selectorPolicy` (type: `object`):

JSON protected/external selectors and project-owned path rules.

## `verification` (type: `object`):

V1 supports STATIC_ONLY only. Customer test, typecheck, build, lint, lifecycle, and arbitrary commands are not executed.

## `limits` (type: `object`):

JSON source, change, runtime, AI request, spend, and repair ceilings.

## `output` (type: `object`):

JSON switches for ZIP, patches, reports, and future rules.

## `consent` (type: `object`):

Source processing authorization. V1 never executes customer project commands.

## Actor input object example

```json
{
  "source": {
    "kind": "IN_MEMORY",
    "files": {
      "src/ProductList.tsx": "import './ProductList.css'; function calc(price:number,quantity:number){return price*quantity} export function ProductList({products}:{products:{active:boolean;price:number}[]}){const data=products.filter((product)=>product.active);if(data.length){return <div className=\"wrap\">{data.map((product)=><span>{calc(product.price,1)}</span>)}</div>}else{return <p>Empty</p>}}",
      "src/ProductList.css": ".wrap{display:grid}"
    }
  },
  "mode": "STANDARD",
  "operation": "APPLY",
  "behaviorChange": false,
  "bugFixPolicy": "OFF",
  "verification": {
    "executionPolicy": "STATIC_ONLY",
    "scripts": [],
    "visualPolicy": "NOT_RUN",
    "routes": [],
    "acceptExistingBaselineFailures": false
  },
  "consent": {
    "sourceProcessingAuthorized": true,
    "sendSelectedSourceToAi": false,
    "executeProjectCodeInSandbox": false
  }
}
```

# Actor output Schema

## `result` (type: `string`):

No description

## `package` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "source": {
        "kind": "IN_MEMORY",
        "files": {
            "src/ProductList.tsx": "import './ProductList.css'; function calc(price:number,quantity:number){return price*quantity} export function ProductList({products}:{products:{active:boolean;price:number}[]}){const data=products.filter((product)=>product.active);if(data.length){return <div className=\"wrap\">{data.map((product)=><span>{calc(product.price,1)}</span>)}</div>}else{return <p>Empty</p>}}",
            "src/ProductList.css": ".wrap{display:grid}"
        }
    },
    "mode": "STANDARD",
    "operation": "APPLY",
    "verification": {
        "executionPolicy": "STATIC_ONLY",
        "scripts": [],
        "visualPolicy": "NOT_RUN",
        "routes": [],
        "acceptExistingBaselineFailures": false
    },
    "consent": {
        "sourceProcessingAuthorized": true,
        "sendSelectedSourceToAi": false,
        "executeProjectCodeInSandbox": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("bread-kim/human-readable-code-refactorer").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "source": {
        "kind": "IN_MEMORY",
        "files": {
            "src/ProductList.tsx": "import './ProductList.css'; function calc(price:number,quantity:number){return price*quantity} export function ProductList({products}:{products:{active:boolean;price:number}[]}){const data=products.filter((product)=>product.active);if(data.length){return <div className=\"wrap\">{data.map((product)=><span>{calc(product.price,1)}</span>)}</div>}else{return <p>Empty</p>}}",
            "src/ProductList.css": ".wrap{display:grid}",
        },
    },
    "mode": "STANDARD",
    "operation": "APPLY",
    "verification": {
        "executionPolicy": "STATIC_ONLY",
        "scripts": [],
        "visualPolicy": "NOT_RUN",
        "routes": [],
        "acceptExistingBaselineFailures": False,
    },
    "consent": {
        "sourceProcessingAuthorized": True,
        "sendSelectedSourceToAi": False,
        "executeProjectCodeInSandbox": False,
    },
}

# Run the Actor and wait for it to finish
run = client.actor("bread-kim/human-readable-code-refactorer").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "source": {
    "kind": "IN_MEMORY",
    "files": {
      "src/ProductList.tsx": "import '\''./ProductList.css'\''; function calc(price:number,quantity:number){return price*quantity} export function ProductList({products}:{products:{active:boolean;price:number}[]}){const data=products.filter((product)=>product.active);if(data.length){return <div className=\\"wrap\\">{data.map((product)=><span>{calc(product.price,1)}</span>)}</div>}else{return <p>Empty</p>}}",
      "src/ProductList.css": ".wrap{display:grid}"
    }
  },
  "mode": "STANDARD",
  "operation": "APPLY",
  "verification": {
    "executionPolicy": "STATIC_ONLY",
    "scripts": [],
    "visualPolicy": "NOT_RUN",
    "routes": [],
    "acceptExistingBaselineFailures": false
  },
  "consent": {
    "sourceProcessingAuthorized": true,
    "sendSelectedSourceToAi": false,
    "executeProjectCodeInSandbox": false
  }
}' |
apify call bread-kim/human-readable-code-refactorer --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bread-kim/human-readable-code-refactorer"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/SQykfu8vl5n0vSnfa/builds/75uwoqMjAaVFco6pc/openapi.json
