r/codereview • • 49m ago

I built an MCP server that makes Claude check whether anyone understands the code before it edits it

Thumbnail gallery
1 Upvotes

r/codereview • • 3h ago

Just because I'm curious

1 Upvotes

First I have no intention of bricking my Nook Glowlight 3 and actually trying this bash script suggested by Brave AI. Now that that is it of the way, I'm planning on rooting said EReader so I can install a custom launcher and all that. While figuring out the steps I needed to take the Brave Assistant kept trying to help, so I thought I would see if it could write a script that would auto complete the rooting process and to my surprise it came back with...

#!/bin/bash

set -e

clear

echo "=== Nook GlowLight 3 Root Script ==="

echo "1. Enable USB Debugging on the Nook first."

echo "2. Plug it in and authorize when prompted."

echo "3. Press Enter when ready..."

read -p " > "

--- Install ADB if missing ---

if ! command -v adb &>/dev/null; then

echo "Installing ADB..."

sudo apt update -qq

sudo apt install -y android-tools-adb

fi

--- udev rule ---

RULE='SUBSYSTEM=="usb", ATTRS{idVendor}=="2080", MODE="0666"'

if ! grep -q "2080" /etc/udev/rules.d/51-android.rules 2>/dev/null; then

echo "$RULE" | sudo tee /etc/udev/rules.d/51-android.rules

sudo udevadm control --reload-rules

echo "Udev rule added. Unplug & replug the Nook, then press Enter."

read -p " > "

fi

--- Wait for device ---

echo "Waiting for device..."

adb wait-for-device

DEV=$(adb devices | grep -w "device" | head -1 | awk '{print $1}')

if [ -z "$DEV" ]; then

echo "ERROR: Nook not detected. Check cable/port."

exit 1

fi

echo "Device found: $DEV"

--- Download & patch root script ---

cd /tmp

if [ ! -d "rooting-nook-glowlight" ]; then

git clone https://github.com/wmahfoudh/rooting-nook-glowlight.git

fi

cd rooting-nook-glowlight

Remove model-number check (the critical fix)

sed -i '/BNRV510/d' rootnook.sh

sed -i '/BNRV520/d' rootnook.sh

Comment out the if-block that tests model

sed -i 's/^if.model./# &/' rootnook.sh

chmod +x rootnook.sh

--- Run root ---

echo "Starting root..."

./rootnook.sh

--- Boot animation fix ---

read -p "Root complete. Fix boot animation bug? [Y/n] " ans

if [[ "$ans" != [Nn]* ]]; then

echo "Rebooting Nook and removing bootanimation..."

adb reboot

adb wait-for-device

adb shell "su -c 'mount -o remount,rw /system && mv /system/bin/bootanimation /system/bin/bootanimation.bak'"

adb reboot

echo "Done. Nook is rooted."

else

echo "Skipping boot animation fix."

fi

So I'm genuinely curious if this would auto complete the root?


r/codereview • • 13h ago

Code review: claiming a filesystem lock for an npm module installer

1 Upvotes

I maintain create-tigra, an MIT npm generator, and would appreciate a focused review of its optional-module installer. Two CLI processes must not modify the same project at once. The installer writes an owner file into a candidate directory before renaming the nonempty directory into the lock location.

Excerpt from lib/installer-transaction.js:

await writeFile(path.join(candidate, mine), '', { flag: 'wx', mode: 0o600 });
const lock = await projectPath(root, INSTALL_STATE, 'directory');
if (!lock.stat) {
  try {
    await rename(candidate, lock.file);
    return lock.file;
  } catch (error) {
    if (!(await projectPath(root, INSTALL_STATE, 'directory')).stat) throw error;
  }
}

The full function then inspects the owner PID and attempts recovery only for a dead owner, claiming its unique filename with another rename.

What concurrent interleaving would you test first? Are there platform-specific rename or process-liveness assumptions that should be made explicit? What would you simplify while preserving crash recovery?

Suggestions, honest feedback, and a roast of the code are welcome. The repository documents known dependency advisories separately; I am asking about this locking/recovery boundary, not asserting that passing tests proves it safe.