Version control, down to the code.

Restore individual blocks of code without reverting entire files. CapState gives developers granular control over their code history.

Get Started Free
pricing.ts
1function calculatePrice(items: Item[]) {|
2 const base = items.reduce((s, i) => s + i.price, 0);
3 const tax = applyTaxLogic(base);
4 const discount = getDiscount(base);
5 const converted = convertCurrency(tax - discount);
6 return converted;
7}
TypeScriptUTF-8
3 blocks tracked

Sometimes you don't want to go back.
You just want one thing back.

Traditional version control forces an all-or-nothing choice. Revert the whole file and lose your latest work, or keep everything and manually reconstruct the old code.

Traditional Git Workflow

6 painful steps

Current file

Working on latest version

01

Something broke

Tax logic fails in production

02

Find older version

Dig through commit history

03

Restore entire file

Revert all changes

04

Lose newer work

3 hours of progress gone

05

Manually reconstruct

Piece it back together

06

CapState Workflow

4 clean steps

Current file

Working on latest version

01

Something broke

Tax logic fails in production

02

Select the block

calculatePrice() at 2:41 PM

03

Restore only that

Everything else untouched

04

2 fewer steps. 0 lost work.

✓ Everything else preserved

Don't roll back the file. Roll back the code.

Restore what changed. Keep what didn't.

Four steps from broken code to working code — without touching a single line you didn't write today.

01

Capture

Tag individual functions, classes, or components for tracking. CapState begins recording every change at the block level from that moment forward.

// capstate.config.ts
export default {
  track: [
    "calculatePrice",
    "UserAuthService",
    "PaymentHandler"
  ]
}
02

Track

Each tracked code block develops its own independent timeline. Changes to other parts of the file don't pollute your block's history.

calculatePrice() history

09:14

Initial impl

11:32

Added caching

14:41

Tax logic v1

16:08

Tax logic v2

03

Compare

Inspect any two versions of a block side by side. Understand precisely what shifted between implementations.

// diff: calculatePrice- const tax = applyTaxLogic(base);+ const tax = base * 0.18;  const discount = getDiscount(base);
04

Restore

One command. The block reverts. Everything else in the file stays exactly as you left it.

$ capstate restore calculatePrice@2:41pm✓ Restored calculatePrice (v2 → v1)✓ 847 other lines untouched

Every block type, covered.

CapState tracks history at the level you actually think about code — not files, not commits, but the blocks that matter.

Functions

Pure functions & utilities

Restore any standalone function to a previous working state without touching the module it lives in.

function calculateDiscount(
  price: number,
  tier: UserTier
): number {
  // v1: simple percentage
  return price * 0.1;
}
$capstate restore calculateDiscount@11:02am
React Components

UI components

Broke a component refactor? Restore the component tree to any point in its history, keeping your other components intact.

export function PriceTag({ amount }: Props) {
  return (
    <span className="price">
      {formatCurrency(amount)}
    </span>
  );
}
$capstate restore PriceTag@yesterday
API Handlers

Route & request handlers

API endpoints evolve fast. Restore a specific handler to a known-good version while your new endpoints stay live.

app.post('/api/checkout', async (req, res) => {
  const { items, userId } = req.body;
  const order = await createOrder(items);
  res.json({ orderId: order.id });
});
$capstate restore checkoutHandler@v2
Algorithms

Core logic & algorithms

Performance regression in a sorting or search algorithm? Roll back the logic without touching the data layer.

function rankResults(
  results: SearchResult[]
): SearchResult[] {
  return results
    .sort((a, b) => b.score - a.score)
    .slice(0, 20);
}
$capstate restore rankResults@before-refactor
Classes

Classes & services

Service classes grow complex. Restore an individual method or the entire class body to a previous checkpoint.

class PaymentService {
  async charge(
    amount: number,
    method: PaymentMethod
  ): Promise<Receipt> {
    return this.gateway.process(amount);
  }
}
$capstate restore PaymentService.charge@2:41pm
Config Blocks

Config & feature flags

Revert a misconfigured feature flag or build config block independently of everything else in the file.

export const featureFlags = {
  newCheckout: true,
  betaPricing: false,
  darkMode: true,
  experimentalAPI: false,
};
$capstate restore featureFlags@before-deploy

12+

Active developers

250+

Blocks tracked

99.8%

Restore accuracy

< 10s

Avg recovery time

01 / 03
CapState changed how I debug. I stopped dreading refactors because I know I can restore any function to exactly how it was — not the whole file, just that one block.
Priya Venkataraman, Senior Engineer at Razorpay

Priya Venkataraman

Senior EngineerRazorpay

3.2h

saved per week

terminal

$ capstate restore calculatePrice@2:41pm

✓ Block restored in 8.2s

✓ 847 other lines untouched

Stop reverting files. Start restoring code.

Join 12+ developers who've stopped losing work to file-level reverts. Install in 30 seconds, start tracking in under a minute.

  • Free forever for solo devs
  • No credit card required
  • CLI + VS Code extension
  • Works with any git repo
terminal

$ npm install -g capstate

$ capstate init

✓ CapState initialized in ./src

Tracking 0 blocks. Run capstate add to start.

$ capstate add calculatePrice

✓ Now tracking calculatePrice

30s

to install

1 cmd

to restore

0 deps

required