|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Lepton is a lean code snippet manager powered by GitHub Gist, built with Electron, React, and Redux. It provides a desktop application for managing and organizing code snippets with features like unlimited public/secret snippets, tagging, markdown/Jupyter notebook support, and GitHub Enterprise integration. |
| 8 | + |
| 9 | +## Tech Stack |
| 10 | + |
| 11 | +- **Framework**: Electron (desktop app) |
| 12 | +- **Frontend**: React + Redux (with Redux Thunk for async actions, Redux Form for forms) |
| 13 | +- **Build System**: Webpack + Babel (ES6 transpilation) |
| 14 | +- **Styling**: Sass/SCSS |
| 15 | +- **Code Editor**: CodeMirror (via react-codemirror) |
| 16 | +- **Linting**: ESLint with Standard config |
| 17 | +- **Dependencies**: Uses yarn package manager |
| 18 | + |
| 19 | +## Key Commands |
| 20 | + |
| 21 | +### Development |
| 22 | +```bash |
| 23 | +# Install dependencies |
| 24 | +yarn install |
| 25 | + |
| 26 | +# Development build and run |
| 27 | +yarn build && yarn start |
| 28 | + |
| 29 | +# Watch mode for development |
| 30 | +yarn webpack-watch |
| 31 | + |
| 32 | +# Production build |
| 33 | +yarn webpack-prod |
| 34 | +``` |
| 35 | + |
| 36 | +### Building & Distribution |
| 37 | +```bash |
| 38 | +# Create installer for current platform |
| 39 | +yarn dist |
| 40 | + |
| 41 | +# Platform-specific builds |
| 42 | +yarn dist -m # macOS |
| 43 | +yarn dist -w # Windows |
| 44 | +yarn dist -l # Linux (requires Docker for snap) |
| 45 | +yarn dist -wml # All platforms |
| 46 | +``` |
| 47 | + |
| 48 | +### Code Quality |
| 49 | +```bash |
| 50 | +# Lint code |
| 51 | +yarn lint |
| 52 | + |
| 53 | +# Check for outdated dependencies |
| 54 | +yarn check-outdated |
| 55 | + |
| 56 | +# Pre-version checks (runs lint + test + outdated check) |
| 57 | +yarn preversion |
| 58 | +``` |
| 59 | + |
| 60 | +### Testing |
| 61 | +The `yarn test` command runs webpack in development mode (essentially a build verification). There are no formal unit tests configured - the project relies on build-time checks and manual testing. |
| 62 | + |
| 63 | +## Architecture |
| 64 | + |
| 65 | +### Application Structure |
| 66 | +- `/app` - Main React application source |
| 67 | + - `/containers` - React container components (connected to Redux) |
| 68 | + - `/reducers` - Redux reducers for state management |
| 69 | + - `/actions` - Redux action creators |
| 70 | + - `/utilities` - Shared utilities (GitHub API, parser, search, etc.) |
| 71 | +- `/configs` - Configuration files including GitHub OAuth credentials |
| 72 | +- `/main.js` - Electron main process entry point |
| 73 | +- `/bundle` - Webpack build output directory |
| 74 | + |
| 75 | +### Key Components |
| 76 | +- **GitHub API Integration**: `/app/utilities/githubApi/` - handles Gist CRUD operations |
| 77 | +- **Theme Management**: `/app/utilities/themeManager/` - light/dark theme switching |
| 78 | +- **Code Rendering**: Uses CodeMirror for syntax highlighting and editing |
| 79 | +- **Search**: `/app/utilities/search/` - snippet search functionality |
| 80 | +- **Configuration**: Uses nconf for config management, stored in `~/.leptonrc` |
| 81 | + |
| 82 | +### GitHub OAuth Setup |
| 83 | +The app requires GitHub OAuth credentials in `/configs/account.js`: |
| 84 | +```js |
| 85 | +module.exports = { |
| 86 | + client_id: '<your_client_id>', |
| 87 | + client_secret: '<your_client_secret>' |
| 88 | +} |
| 89 | +``` |
| 90 | +Register your application at https://github.com/settings/applications/new |
| 91 | + |
| 92 | +## Development Notes |
| 93 | + |
| 94 | +- **Electron Version**: Uses Electron 13.x with @electron/remote for main-renderer communication |
| 95 | +- **ES6 Support**: Babel transpiles ES6+ to support older Electron versions |
| 96 | +- **Hot Reloading**: Use `yarn webpack-watch` for auto-rebuilding during development |
| 97 | +- **Styling**: Uses Sass with component-level SCSS files |
| 98 | +- **State Management**: Redux store handles application state, actions use Redux Thunk for async operations |
| 99 | +- **Shortcuts**: Customizable keyboard shortcuts defined in config, registered via electron-localshortcut |
| 100 | + |
| 101 | +## Configuration |
| 102 | + |
| 103 | +The app uses a hierarchical configuration system: |
| 104 | +1. Default config in `/configs/defaultConfig.js` |
| 105 | +2. User config in `~/.leptonrc` (JSON format) |
| 106 | +3. Environment variables and command line args |
| 107 | + |
| 108 | +Key configuration areas include theme, shortcuts, proxy settings, editor preferences, and GitHub Enterprise support. |
| 109 | + |
| 110 | +## Important Guidelines |
| 111 | + |
| 112 | +When working with this codebase: |
| 113 | +- **NEVER modify `node_modules/`** - this directory contains installed dependencies and should not be edited |
| 114 | +- **DO NOT commit `yarn.lock`** unless specifically updating dependencies - this file locks dependency versions |
| 115 | +- **DO NOT change LICENSE files** unless told |
| 116 | +- Focus code changes on the `/app` directory, `/configs`, `main.js`, and configuration files |
| 117 | +- Avoid searching or reading files in `node_modules/`, `/bundle`, `/build`, `/dist` directories unless absolutely necessary |
0 commit comments