Skip to content
dabstractorPublic

About

A workspace tooling layer for git projects

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Jin - Phantom Git Layer System

Manage developer-specific and tool-specific configuration without contaminating your project's Git repository.


What is Jin?

Jin is a meta-versioning system layered on top of Git that manages developer-specific and tool-specific configuration (like .claude/, .cursor/, .vscode/ settings) across multiple projects without polluting your primary Git repository. Think of it as "Git for your ignored files" with a powerful 9-layer precedence system.

Key Benefits:

  • Non-disruptive: Works alongside Git, only touches ignored/untracked files
  • Deterministic: Structured files (JSON/YAML/TOML) merge predictably across layers
  • Team-friendly: Share base configurations while preserving local customizations
  • Remote sync: Collaborate on tool configurations via shared repository

Quick Start

Installation

Install via Cargo:

cargo install jin

Or build from source:

git clone https://github.com/jin/jin
cd jin && cargo build --release
cp target/release/jin /usr/local/bin/

Your First Jin Workflow

Initialize Jin in your project (project identity is inferred from your Git remote):

$ jin init
Jin initialized in current project
Project: ui-dashboard (source: git-remote-origin)

Create and activate a development mode:

$ jin mode create dev
Mode 'dev' created

$ jin mode use dev
Mode 'dev' activated

Add configuration to mode layer:

$ echo '{"debug": true}' > .dev/config.json
$ jin add .dev/config.json --to mode
Staged .dev/config.json to mode layer

$ jin commit -m "Add dev configuration"
Committed to mode/dev layer
Applied 1 file to workspace:
  .dev/config.json

jin commit applies the merged result to your workspace by default. Pass --no-apply to commit without applying.

Check the state of your workspace at any time (includes project identity and per-file layer provenance):

$ jin status
Active mode: dev
Project: ui-dashboard (source: git-remote-origin)
Workspace: clean
Files tracked: 1

  .dev/config.json  → mode/dev

That's it! Your configuration is now managed by Jin.

Next Steps

  • Explore commands: Run jin help or jin <command> --help for detailed usage
  • Create modes: Use jin mode create <name> to set up environment-specific configurations
  • Create scopes: Use jin scope create <name> for nested configuration contexts
  • View layers: Run jin layers to see the 9-layer merge hierarchy

Installation

Via Cargo (Recommended)

If you have Rust installed:

cargo install jin

Via Homebrew (macOS)

brew install jin  # (if packaged)

Build from Source

Prerequisites: Rust 1.70.0+ (install from rustup.rs)

git clone https://github.com/jin/jin
cd jin
cargo build --release
cargo test  # Verify build

Binary will be at target/release/jin. Add to your PATH.

Command Overview

Jin provides 32 commands organized by function:

Core Commands: init, add, commit, status, context

Mode Management: mode create|use|list|delete|show|unset, modes (list modes)

Scope Management: scope create|use|list|delete|show|unset, scopes (list scopes)

Workspace Operations: apply, reset

jin commit applies the merged result to your workspace by default; pass --no-apply to skip the apply step.

Remote Sync: link, fetch, pull, push, sync

Inspection: diff, log (optionally by layer, e.g. jin log mode), layers, list, repair

Utility: completion

For complete reference, run jin help or use --help with any command.

Documentation

Jin includes built-in help for all commands:

  • jin help - Show all available commands
  • jin <command> --help - Show detailed help for a specific command
  • jin help modes - Show mode management help
  • jin help scopes - Show scope management help

Why Jin?

Traditional approaches to developer configuration management have problems:

Problem 1: Git Pollution

Committing .vscode/, .claude/, .cursor/ settings to Git pollutes the repository with tool-specific configuration that doesn't belong there.

Problem 2: Ignored Files Lost

Adding them to .gitignore means they're not versioned and can't be shared across machines or with teammates.

Problem 3: Manual Synchronization

Developers resort to copy-pasting config files between machines, leading to drift and inconsistency.

Jin's Solution:

Jin creates a separate "phantom" Git layer that versions ignored files independently from your main repository, with a 9-layer precedence system for sharing base configurations while allowing local overrides.

How Jin Works

Jin introduces a phantom Git layer that:

  1. Only touches files that are ignored or untracked by your main Git repository
  2. Stores configurations in a separate Git repository at ~/.jin/
  3. Merges configurations from multiple layers based on active mode and scope
  4. Applies the merged result to your workspace deterministically

Layering System

Jin uses a 9-layer hierarchy where higher layers override lower layers:

Layer 9: Workspace Active (merged result, highest precedence)
Layer 8: User Local (machine-specific)
Layer 7: Project Base (project-specific)
Layer 6: Scope Base (scope defaults)
Layer 5: Mode → Project
Layer 4: Mode → Scope → Project
Layer 3: Mode → Scope
Layer 2: Mode Base (mode defaults)
Layer 1: Global Base (shared defaults, lowest precedence)

Run jin layers to see the live layer composition and merge order in your workspace. Its file total counts unique workspace paths, consistent with jin status and jin apply.

Configuration Directory

Jin stores its internal Git repository and configuration data in a directory controlled by the JIN_DIR environment variable.

Default Location

By default, Jin uses:

  • Linux/macOS: ~/.jin/
  • Windows: %USERPROFILE%\.jin\

This directory contains:

  • config.toml - Global Jin configuration (remote URL, user settings)
  • Internal Git repository - Stores layers, refs, and objects
  • Cached data and metadata

Customizing JIN_DIR

You can override the default location by setting the JIN_DIR environment variable before running Jin commands:

# Set custom Jin directory
export JIN_DIR="/custom/path/to/jin"

# All subsequent Jin commands use this location
jin init
jin mode create dev

Important: JIN_DIR must be set before running any Jin commands, as it is read at process startup.

Use Cases

Different Drive or Partition: Store Jin data on a different drive to save space on your system drive:

# Linux/macOS
export JIN_DIR="/mnt/storage/jin"

# Windows (PowerShell)
$env:JIN_DIR = "D:\jin"

Network Storage: Share Jin configuration across multiple machines via network mount:

export JIN_DIR="/mnt/network-shared/jin"

Isolated Testing: Create separate Jin environments for testing without affecting your main setup:

# Create test environment
export JIN_DIR="/tmp/jin-test"
git init test-project && cd test-project
jin init
# ... run tests ...

# Return to production (uses default ~/.jin/)
unset JIN_DIR

CI/CD Environments: Configure Jin for CI pipelines with non-standard home directories:

# GitLab CI, GitHub Actions, etc.
export JIN_DIR="$CI_PROJECT_DIR/.jin"
jin sync

Making JIN_DIR Persistent

To make JIN_DIR persist across shell sessions, add it to your shell configuration:

Bash (~/.bashrc or ~/.bash_profile):

export JIN_DIR="$HOME/.local/share/jin"

Zsh (~/.zshrc):

export JIN_DIR="$HOME/.local/share/jin"

Fish (~/.config/fish/config.fish):

set -x JIN_DIR "$HOME/.local/share/jin"

PowerShell ($PROFILE):

$env:JIN_DIR = "$env:USERPROFILE\.local\share\jin"

After adding to your shell config, reload your shell or run source ~/.bashrc (or equivalent).

Directory Structure

Inside JIN_DIR, you'll find:

$JIN_DIR/
├── config.toml           # Global configuration (remote URL, user info)
├── refs/                 # Git references
│   └── jin/             # Jin-specific refs (layers, modes, scopes)
├── objects/             # Git objects (blobs, trees, commits)
└── jin/                 # Jin metadata (if present)

This is a standard bare Git repository structure, which you can inspect with Git commands:

# List all Jin layers
git --git-dir=$JIN_DIR show-ref | grep refs/jin/layers

# View Jin configuration
cat $JIN_DIR/config.toml

Example Use Cases

Developer Configuration

Share VS Code, Cursor, or Claude settings across projects while preserving personal preferences:

# Share base settings with team (routed to the active mode)
jin add .vscode/settings.json --to mode

# Personal machine-specific overlays (--local is shorthand for --to local;
# never pushed, applies on this machine everywhere)
jin add .vscode/personal.json --local

# Scope-targeted config (--scope implies the scope layer; no --to needed)
jin add .cursor/config.json --scope editor:cursor

--mode <name> and --scope <name> are value selectors: with --to omitted, --mode alone implies the mode layer, --scope alone implies the scope layer, and both together imply the mode-scope layer. An explicit --to always wins.

Environment-Specific Configuration

Different configs for development vs. production:

# Development mode
jin mode create dev
jin mode use dev
jin add .env --to mode              # → mode/dev/

# Production mode
jin mode create prod
jin mode use prod
jin add .env --to mode              # → mode/prod/

Tool-Specific Workflows

Separate configurations for different AI tools:

# Claude mode
jin mode create claude
jin mode use claude
jin add .claude/ --to mode          # → mode/claude/

# Cursor mode
jin mode create cursor
jin mode use cursor
jin add .cursor/ --to mode          # → mode/cursor/

Multi-Machine Sync

Share configurations across machines through a shared Git remote. Project identity — including org/repo slugs like myorg/ui-dashboard — is inferred from your Git remote at jin init:

# Machine 1
$ jin init
Project: myorg/ui-dashboard (source: git-remote-origin)

$ jin add .vscode/settings.json --to mode
$ jin commit -m "Base editor settings"
$ jin link [email protected]:team/jin-configs.git
$ jin push

# Machine 2
$ jin init
$ jin link [email protected]:team/jin-configs.git
$ jin pull

# Modes and scopes arrive with the pull — activate them directly
$ jin mode use claude
$ jin scope use language:javascript

jin push and jin pull transfer both layer content and the mode/scope registry, so a receiving machine can list and activate modes and scopes immediately after pulling — no recreating. Promotion on pull is first-writer-wins: a mode you created locally before pulling is never overwritten by the remote's registry entry.

jin fetch groups its report by relevance: updates touching your active mode, scope, or project appear under "Updates for your active context (mode: …, scope: …)", with all other updates listed separately.

File Lifecycle (rm / mv)

jin rm and jin mv work on staged and committed files alike, using the same routing flags as jin add:

# Remove a committed file from the mode layer (stages a deletion; commit required)
$ jin rm .dev/config.json --to mode
$ jin commit -m "Remove dev configuration"
# If a lower layer still provides the file, it reappears on the next apply

# Rename within a layer (content is carried over, even if the workspace copy is gone)
$ jin mv .dev/config.json .dev/settings.json --to mode --force

# Move a file between layers in one step (rm + add; the source layer is detected automatically)
$ jin mv .dev/config.json .dev/config.json --to project

jin rm on a still-staged file unstages it and stages the deletion instead. jin mode delete <name> removes a mode completely — its registry entry and every layer ref it owns — so a re-created mode starts fresh.

Features

  • 9-Layer Precedence System: Global → Mode → Scope → Project → Local with deterministic merging
  • Deep Merge for Structured Files: JSON, YAML, TOML files merge intelligently by key. Files that fail to parse (including JSONC with comments, e.g. .vscode/settings.json) fall back to byte-exact handling, so jin apply and jin diff are never blocked by malformed content
  • Safe Add Paths: ./ prefixes are normalized (so jin add . stages the real workspace files); ../ and absolute paths are rejected with a clear error; Jin's own internal state (.jin/, .jinmap, .paused_apply.yaml, *.jinmerge) is never staged
  • 3-Way Merge for Text Files: Conflict resolution like Git for text files (binary files are never merged — the higher layer wins)
  • Project Identity at Init: Your project is inferred automatically from the Git remote at jin init
  • Per-Project Workspace Isolation: Two projects sharing one JIN_DIR never see each other's state
  • Semantic Comparison & Canonical Apply: Formatting-only differences in structured files are not dirty; the canonical form is written on apply
  • Binary File Support: Binary files are stored, applied, and diffed as opaque blobs ("binary files differ"); never merged — the higher layer wins. Large binaries are out of scope.
  • Commit Applies by Default: jin commit writes the merged result to your workspace; opt out with --no-apply
  • Per-File Layer Provenance: jin status and jin apply show which layer each tracked file comes from
  • Mode & Scope Management: Organize configurations by development environment and context
  • Remote Synchronization: Share configurations via Git-based remote repository
  • Atomic Operations: All commits are atomic and reversible
  • Automatic .gitignore Safety: Jin-managed files are auto-ignored in main Git repo
  • Shell Completion: Bash, Zsh, Fish, PowerShell support

Contributing

Contributions welcome! See CONTRIBUTING.md for guidelines.

License

MIT License - See LICENSE for details


Questions? Open an issue.

About

A workspace tooling layer for git projects

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages