explainit
v1.0.4
Published
π§ AI-powered CLI that quizzes you on your code before you commit
Downloads
38
Maintainers
Readme
π― the problem
# you copy this from ChatGPT
function generateToken(user, secret, expiresIn) {
return jwt.sign({ id: user.id, email: user.email }, secret, { expiresIn })
}
# it works. you commit it.
git commit -m "add auth"
# 6 months later β production is down.
# nobody can explain what expiresIn does.
# including you.explainit fixes this.
β¨ how it works
git add .
git commit -m "add auth"π§ explainit β quick check before commit
ββββββββββββββββββββββββββββββββββββββββββ
lib/auth.js β 18 lines changed
What does the expiresIn parameter control in generateToken?
Your answer: it sets how long the JWT token stays valid
β Exactly right β expiresIn defines the token lifetime in seconds.
A high value means stolen tokens stay valid longer.
[main 3f2a1] add authOne question. Fifteen seconds. You just learned something about the code you're shipping.
π install
npm install -g explainitrequires Node.js 18+
β‘ quick start β 4 steps, under 2 minutes
step 1 β install
npm install -g explainitstep 2 β get a free Gemini API key
aistudio.google.com/apikey β sign in with Google β Create API key in new project β copy it
completely free Β· no credit card required Β· 1,500 requests/day per user
step 3 β connect your key
explainit setupβΈ setup β gemini api key
ββββββββββββββββββββββββββββββββββββββββββββ
get your free key at:
β https://aistudio.google.com/apikey
steps:
1. sign in with google
2. click 'create api key in new project'
3. copy and paste below
β paste your gemini key: ββββββββββββββββββββ
β api key saved!
you're all set β run explainit install to hook into gitstep 4 β hook into git
explainit installβΈ installing git hook
ββββββββββββββββββββββββββββββββββββββββββββ
β git hook installed
β run-quiz.js created
β every git commit will now trigger a quiz automaticallyyou're done. every git commit from now on will trigger a quiz automatically.
π full workflow
npm i -g explainit
β
explainit setup β paste your free Gemini API key
β
explainit install β hooks into your git repo
β
git add .
β
git commit -m "your message"
β
explainit detects changed files
β
skips small changes βββ commit goes through silently β
β
Gemini reads your code
β
1 question appears in terminal
β
you type your answer
β
instant AI feedback
β
commit goes through regardless βexplainit never blocks your commit. it only teaches. adoption comes from being useful, not forceful.
π¦ commands
| command | description |
|---|---|
| explainit setup | connect your free Gemini API key |
| explainit install | hook into git (run once per project) |
| explainit scan <file> | preview a file and its contents |
| explainit quiz <file> | manually quiz yourself on any file |
| explainit score | view your progress, history and streak |
π track your progress
explainit score total quizzes 12 correct 9 wrong 3
score 75% streak 4 days
ββββββββββββββββββββββββββββββ 75%
βΈ recent activity
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β auth.js 27 Mar, 14:32 What does bcrypt.compare do?
β quiz.js 27 Mar, 12:10 Why is snippet sliced to 300...
β scores.js 26 Mar, 09:44 What does getStreak return?
β ai.js 25 Mar, 18:21 Why is code sliced to 300 chars?
βΈ most quizzed files
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β auth.js 5 quizzes 80% correct
β quiz.js 4 quizzes 75% correct
β ai.js 3 quizzes 66% correctπ api key β per user, always free
explainit uses a bring your own key model.
each user provides their own free Gemini API key. this means:
- β no shared quota β your usage never affects anyone else
- β completely free β 1,500 requests/day is more than enough
- β scales to any number of users
- β your key is stored locally at
~/.explainit/config.json - β nothing leaves your machine except API calls to Gemini
get your free key at aistudio.google.com/apikey
ποΈ architecture
explainit/
βββ bin/
β βββ explainit.js β CLI entry point β all commands
βββ lib/
β βββ ai.js β Gemini API β generate & evaluate
β βββ quiz.js β quiz loop β questions & answers
β βββ scores.js β local score storage & streak logic
βββ run-quiz.js β git hook bridge (auto-created on install)
βββ package.jsonπ οΈ tech stack
| tool | purpose | |---|---| | Node.js | runtime | | Commander.js | CLI framework | | Gemini API | AI question generation & evaluation | | Chalk | terminal colours & styling | | Ora | terminal spinner |
π€ contributing
contributions, issues and feature requests are welcome!
# clone the repo
git clone https://github.com/shekharrs/explainit.git
cd explainit
# install dependencies
npm install
# link locally for development
npm link
# test your changes
explainit setup
explainit install
explainit scan bin/explainit.js
explainit scoreto contribute:
- fork the project
- create your branch Β Β
git checkout -b feature/amazing-feature - commit your changes Β
git commit -m "add amazing feature" - push to the branch Β Β Β
git push origin feature/amazing-feature - open a pull request
π roadmap
- [x] auto-quiz on git commit via pre-commit hook
- [x] AI question generation with Gemini
- [x] answer evaluation with instant feedback
- [x] local score tracking and streak system
- [x] per-user API key β bring your own key model
- [x] first-time setup wizard
- [ ] VS Code extension
- [ ] support for more languages (Go, Rust, Java)
- [ ] team leaderboard mode
- [ ] weekly email digest of your weakest files
- [ ]
--strictmode that requires 70%+ to commit
π issues & support
found a bug? have a feature idea?
β open an issue
π license
MIT Β© Shekhar
built for developers who actually want to understand their code
if explainit helped you β drop a β on the repo. it means a lot.
