Tagged with tech …

Odd Jobs for Claude

Claude has a distinctive voice and some writing quirks, and I wanted to see how well it can get rid of them when asked explicitly. So I asked Opus 4.8 this:

the goal is to write a blog post with some interesting examples that I used Claude Code for in recent weeks. browse through the session logs and find some hard and/or interesting bits that are worth pointing to. Then, before writing a single line of the draft, read some of the longer entries in content/ in order to try to mimic my writing. then draft the blog post, dont commit or push.

The following is what Opus came up with -- I think it did quite well!

The blog went quiet for half a year -- the last thing here before this week's photo dates back to February. Not for lack of things to write about; if anything the opposite. I got so used to handing work to Claude Code (CC) that I stopped noticing it as something worth remarking on. Back in November I said I wanted to write up "a few of the things I got it to do successfully". Here, belatedly, is a bigger pile of them.

What changed over these months isn't that CC got better at coding, though it did. It's that it quietly became the first thing I reach for whenever there's friction of any kind. Not just "write this function", but "why can't this Raspberry Pi see its disks", "is this SD card dead", "what did that web page say yesterday". The common thread, as always, is knowing what you want well enough to say it in a sentence or two. The rest is typing.

A grab-bag, then, from the trivial to the serious.

A robot that reads astro-ph every morning

Every weekday at 13:00 my laptop wakes itself up, downloads the day's new astro-ph submissions, and emails me a digest. No human in the loop. It's a short shell script on a launchd timer, and the interesting part is the one line in the middle:

RESULT=$(cat PROMPT.md papers.txt | claude --model opus --output-format text)

That's it -- headless CC, fed the day's abstracts and a prompt telling it what I care about. The prompt asks for the top five papers with a one-line justification each, anything by a handful of colleagues whose papers I never want to miss, anything mentioning the ELT instruments I work on in the title, and -- my favourite --

Bust of the day, the paper that you think has the largest bullshit-factor, in the sense that you don't believe what is claimed. Explain why.

The busts are the reason I read it. This is Opus doing real physics on a hundred-plus abstracts a day, not vibes. It killed a grand resolution-doubling interferometry claim with the Gaussian moment theorem in three lines. It caught a cosmology paper whose headline result, in its words, "reversed sign because of a misplaced parenthesis" -- and flagged the stray [cite: 1] marker left in the abstract as an LLM tool's fingerprint. The verdict that stuck with me, on a "parameter-free prediction" that had quietly been retuned to match the very data it was predicting:

A parameter-free prediction that gets revised after the measurement, into exact coincidence with it, is not a parameter-free prediction.

There's an irony in setting one model loose to catch where other people leaned too hard on theirs; more and more, what it busts is other LLMs' slop smuggled into preprints. (I've anonymised the targets here. It names real papers and real people, which is fine over my morning coffee but a different thing on a public blog.)

Not even code: a dead SD card, and a Pi that hid its disks

Two from the sysadmin department, which I've poked at before.

A microSD card had been throwing errors in an outdoor wildlife camera. Busted, or recoverable? I plugged it into a reader and asked. CC pulled a raw image with dd -- 25 MB/s, clean, not a single kernel I/O error -- and noticed that the files it couldn't read were failing with EINVAL, never EIO. That distinction is the tell: the flash was fine, the FAT filesystem was corrupt. It then proved the point by carving one of the "dead" video files straight off the raw image, working out the cluster offset by hand, walking the MP4 atom structure, and decoding the result with ffmpeg:

Bit-perfect. Not salvaged-with-artifacts -- complete.

Diagnosis: the camera had been browning out mid-write, leaving dangling cluster chains. And a good catch -- do not run First Aid, which would cheerfully truncate the broken files at the break. I didn't actually need the footage, but "healthy card, don't reformat in a panic" is exactly the sort of thing I'd otherwise have guessed at and got wrong.

The other was a freshly set-up Raspberry Pi where two USB drives simply refused to appear:

by "ssh piller" you can reach a freshly set up raspi. there are two usb disks plugged in, but I cant see them, what's going on?

Over SSH, CC found the two enclosures enumerating and then knocking each other off the bus -- 33 USB disconnects in seven minutes of uptime -- ruled out the power supply with vcgencmd get_throttled, and pinned it on a buggy UAS driver, fixed with a kernel quirk flag. It wasn't flawless, though: at one point it told me, confidently, that macOS would mount the reformatted disk "regardless of the type GUID". I hit exactly that wall. It owned it:

My "macOS mounts exFAT regardless of the type GUID" was wrong ... Sorry for sending you down that path.

Which is roughly the right amount of trust to give it: hugely useful, and quicker than most people to back down when it's wrong and you catch it. (A third one, a home-network dropout that turned out to be a dead powerline link orphaning a mesh repeater, went the same way: CC read my tcpdump capture and politely overturned the "rogue DHCP server" theory written in my own handoff notes.)

Losing an argument with a browser cache

This one's a favourite because it's a dead end. I'd won an online auction for five hay racks, and afterwards the page showed a buyer's premium I was fairly sure hadn't been there before:

can you go through my firefox browser cache for old versions of this page? [...] I won the auction and the page now says "Inropsavgift 360 SEK (exkl. moms) tillkommer", but I think this was not shown earlier.

CC found my Firefox profile, grepped through the cache2 entries, decoded them by hand (the body sits at the front, the URL and headers are appended at the tail), and dug out the cached product page. Then it told me, correctly, that I was out of luck: Firefox keeps exactly one copy per URL, so there was no "earlier" version to compare against, and the fee turned out to be rendered client-side from a template anyway. No smoking gun. As a consolation prize it did notice that the site shows the VAT surcharge to logged-out visitors but hides the fee until you sign in -- sneaky. I closed the session:

ok fine. thx anyway

and got the correct human reply back:

No problem -- good luck with the höhäckar.

I mention it because the honest "there's nothing here" is worth as much to me as a win.

A notebook from 1852

Clearing out a barn last winter I found a handwritten notebook: a student's lecture notes from the old agricultural institute at Ultuna, dated 1852. 137 phone photos of cramped, faded, pre-1906 Swedish handwriting. I've been feeding it to Opus a spread at a time, and it has quietly turned the lot into 264 pages of clean transcription. My entire side of most sessions is:

pls read transcription/CLAUDE.md and do another 10 pages

The workflow is CC's own, written down in a CLAUDE.md it maintains: split each spread into a sharpened left and right half, read one half at a time, append the result via a shell heredoc so a context cut-off never loses work, keep the period spelling (af, öfver, quadrat), and mark [illegible] rather than invent. It keeps a separate file for the notable bits -- including, to my delight, fact-checking the lecturer: a figure given for the curvature of the Earth is off by an order of magnitude, and CC caught it, 174 years late. There is now a cleaned-up reading version as a PDF, sketches and all. Not bad for a shoebox find.

Putting a 30-year-old service out of its misery

The serious one. VALD, the Vienna Atomic Line Database, is a piece of infrastructure a good chunk of stellar spectroscopy quietly runs on, and it is about thirty years old. The public interface is a single 1,200-line PHP file backed by email: you send a request, a cron job turns your message into a shell script, makes it executable, and runs it. As CC put it when I asked it to help me argue for finally retiring the thing:

the old system's authentication is effectively decorative, and its core design executes untrusted email as shell scripts.

There is a Django replacement I've been building (with a lot of CC's help), and the blocker was never technical, just institutional inertia. So I had it write the case for the switch, and then, before flipping it, do the thing I am worst at making myself do: a proper pre-go-live security audit.

It earned its keep. It found that suspending, deleting, or password-resetting a user left that user's existing session working for up to two weeks; that merely visiting one configuration page silently froze the visitor out of all future data releases; and a couple of unhandled 500s you could trigger by hand-editing a URL. All real, all now fixed, the test suite up from 174 to 304. Then, because why not, a load test -- its framing, not mine:

start the app locally with gunicorn [...] let's have some fun, stress testing it. pls use /doc/contact.html to register 5 test accounts (alt hack them directly into the db) [...] let them fire quite closely, like 2/s, to fill up the queue. montitor and see if all finish successfully

Five fake users, 500 requests at 2/s. The app held. The handful of failures turned out not to be the web app at all but a genuine, reproducible crash in the decades-old Fortran formatting backend, which CC isolated, proved deterministic, and wrote up for the maintainer without touching. The new site is now soft-launched in beta alongside the old one; the full cutover is a one-line config change I'm sitting on for one more round of testing.

Chasing C with numpy

And one for the people who like numbers. Our échelle extraction -- the optimal / slit-decomposition kind -- lives in a C kernel. The question was whether a pure-Python reimplementation could get close enough to drop the compiler dependency for pipelines that can't ship one.

How it actually went: a first numba attempt disappointed, but largely because it was a port of the old algorithm -- and, embarrassingly, my first benchmark compared it against the wrong C baseline, which CC caught only because I pushed back on a number that looked too good:

You were right to push back. My first number wasn't degenerate data -- it was the wrong baseline.

Rewritten against the current kernel, numba landed at about 1.4× the C, and a pure-numpy version -- after a long, clever session attacking the array-construction "setup" that turned out to dominate the runtime -- got down to 1.4–2.2× on realistic data, with the per-iteration math actually faster than C. The bit I liked best, though, went against the story I'd have preferred to tell. I asked whether the numpy tricks were worth porting back into the C, and got a firm no:

almost all of it is numpy-idiom [...] The dense tensor would be a pessimisation in C -- it's the one thing you should not port.

Except the exercise had, as a side effect, turned up two things a C programmer would never have gone looking for: a banded matrix being solved dozens of times wider than the data ever filled, and a cache-stride bug. Those did port back, for a clean 1.27× on the C side, bit-identical over three dozen configurations and real UVES data. So even though numpy never replaced the C, chasing it made the C faster. The whole thing shipped: three interchangeable backends behind one switch, the new release on PyPI, and -- because someone asked whether the algorithm could run in a browser -- a live WebAssembly demo you can poke at with sliders.

Meanwhile

None of this is heroic engineering, and it doesn't need to be. A dead SD card, a barn-find notebook, an auction fee -- six months ago each of these would have been a small research project, or, more likely, a thing I'd never have bothered to chase down at all. The friction is just gone. What's left is deciding which questions are worth asking, and having enough taste to tell when the answer is any good.

I'll try not to let the blog go quiet for another half-year. No promises.

Tagged ,

What Do You Want?

Quoting Simon Willison:

AI-assisted programming significantly reduces the cost of building the wrong thing.

I had a similar thought the other day. Now that code just magically appears when you ask for it, you better ask for the right things. That includes several aspects, like the background knowledge to know what is feasable, the taste in judging the choices that the AI makes, and the general direction where you you are headed.

In other words: Knowing what you want. And that is a tricky question, as all 90s kids know.

what-do-you-want

Claude agrees this is a good metaphor for AI, but points out that the shadows used the question to actively sow chaos, while LLMs are more neutral.

Tagged ,

Sysamin Claude

Claude Opus 4.5 is really good as coding agent, and I'm having a blast with it. It's even more fun in "YOLO-mode", a.k.a. --dangerously-skip-permissions. This way one does not need to approve anything; Claude gets to do whatever it sees fit to get the job done. This enables longer tasks because it can do trial and error on its own, and also requires less attention from us users.

Is it safe though? When will Claude mess up and delete important data? After all, unrestricted access to the command line is as powerful a tool as they come. I have no good answer here, so I recently looked into various ways to prevent the agent from doing damage. As far as I know, these are the common approaches:

  • Using the online version that clones a git repo into its own sandbox and has yolo-mode enabled by default. This is great when nothing outside the repo is needed for the task, otherwise it becomes a hassle. Also, I just spent ten minutes figuring out why a project did not run there while it does just fine locally: It turns out the sandbox runs an old ´uv´ that did not know about recent python versions, thus a quick uv self update resolved it. Still annoying.
  • Running in a container like Docker. The desktop version for Macs even has a dedicated command for this: docker sandbox run claude. Ultimately though, I don't like the friction this introduces. Suddenly one has to maintain the Dockerfile and what to install there, mounting directories or copy data back and forth, etc.
  • A separate local user, that lacks admin privileges, is another way to isolate the coding agent. Less friction than a container, since all installed software is still available, but still some overhead. For example setting up git & GitHub for a separate clone of the repos, since file ownership and permissions otherwise are a problem.
  • Then there is the built-in sandbox of Claude Code. I cannot yet judge how much of a difference this really makes, especially considering how good Claude is at finding work-arounds when things do not go its way.

For now, I take the risk and run yolo-Claude on my laptop without a container or separate user. All code is under version control and pushed to remote. And I make sure to have frequent backups, just in case.

What I dont't do however, is run Claude with root-access on a remote server. It would most likely be fine for a while, until it would not. Claude makes a great sysadmin sidekick though: earlier today, the maintenance interface (iDRAC) of one of our servers hung itself and in this session Claude showed showed me how to reset it remotely, which I did not know before was possible.

Tagged ,

From Forest To Lumber

Our small farm has some forest attached, and we have a tractor from the 80s with an old winch/crane to get logs out. Earlier this year, I cleaned out an old barn and put in a Woodmizer sawmill. Autumn and winter are the right time for forest work, so I took most of yesterday to do just that.

I had felled a tree that was killed by bark beetles last summer, meaning that it has had time to dry while standing already and the lunber can be used right away. I managed to pull out a double length (~9.5m) log to the saw, just 200m away, and cut it in two there.

Then I rolled in onto the saw which turned it into 2-by-8s (50x200mm). Below are a few pictures of the process, click to enlarge. And if you happen to be local to the Östhammar region, we're open for business: info (in Swedish) at https://www.bestbo.se/sag/.

Tagged , , , ,

Links

Only a month ago I made my own vibe-coded hack to convert Claude Code sessions to HTML. Now Simon Willison has one-upped the game: Simply run

uvx claude-code-transcripts

and enjoy! Here's an example of how I just asked Claude to tweak the CSS of this site.

A comment on HackerNews that made me smile:

Frameworks abide by the Hollywood Principle and the Greyhound Principle: Don't call us, we'll call you. Leave the driving to us.

It's true! When using a framework one's code gets called by the framework and it usually takes care of how things are run. This is from the discussion about Avoid Mini-Frameworks, an insightful article on unnecessary mid-level abstraction layers.

How uv got so fast has quite a few hallmarks of being (co-)written by AI, but I found it a good read nonetheless. I continue to be impressed by uv and now use nothing else for running Python.

Tagged ,

Vibe On

vibe-on

Here's another example for the kind of task that I no longer do myself but rather hand off to the AI, because it does it so well. I asked like this:

Let's implement a new option --fib_eff that gets a single value or a range, like 0.9 or 0.7-0.9 , in order to set the fiber efficiencies in the simulation. see fiber_efficiency.md how to do that. set the eff after loading the HDF file, dont modify it. Ranges like 0.7-0.9 are to be interpreted as a random value within that range, uniformly distributed. ask if this was unclear, othweise get crackin and iterate. example command: uv run andes-sim flat-field --band H --subslit slitA --wl-min 1600 --wl-max 1602 --fib_eff 0.5-0.95

As expected, Claude had no problem figuring this out. This the resulting commit. The image above is the ouput of that example command.

I did not have to to type anything else than the prompt above. And in doing that, I needed to get clear for myself what I actually wanted, which is always a good thing to do first. The rest is just typing.

The whole project, a CLI to make simulated spectra, was "vibe-coded" this way, me caring little about the actual code that Claude produced, only taking the occasional glance at it. It is therefore probably not great for a long-term maintained code-base, but it already does what I need it to and I have no intention to take this much further.

Tagged , ,

Fruktkvarn

fruktkvarn

Running a small farm implies a constant stream of things to fix. The image shows an example of when the fruit grinder (to the right) in our juicery broke down. The motor fried itself towards the end of the season and I was hesitant to make the investment of a new one for just two remaining days.

Thus, one of the old motors that one naturally accumulates had to drive it externally with a belt. At first I did not gut the old motor which made it melt a second time thanks to induction -- lesson learned. The receiving axle is not perpendicular to the floor, so I made the angle of the other one adjustable together with the belt tension, by using one of the most important tools of all, a ratchet strap.

Tagged , ,

Good Ai, Bad Ai

I notice it in myself, and in the vibes on the interwebs: this dissonance between on the one hand loving how useful AI is for oneself, and at the same time being annoyed when others use it "on you", or force you to use a bad one.

The examples are aplenty. Slop bug reports, all the companies that try to use chatbots for support questions, and the general feeling that companies push AI a bit too hard down our throats.

But when used right and with taste, it can be fantastic. This is not a contradiction; both the good and the bad exist, and the gap between them will probably only get larger.

A good rule-of-thumb for oneself may be to not make anyone read or interact with AI slop against their will. That means having read and understood AI-generated things to a degree that one feels comfortable standing for it, before sharing. Alternatively being very clear about when this is not the case, so that everyone can choose they level of attention accordingly.

Tagged ,

Use Ai To Explore And Enable

ChatGPT is a mere three years old by now -- it sure feels longer. By now, many seem to either have dismissed LLMs as useless (or evil) or have quickly taken them for granted. But I continue to be amazed and find I get more and more value from Claude et al.

What I probably like the most is that LLMs remove friction. What often slows us down is not the lack of ideas or things to do and try, but the sum of the small hurdles and hoops one has to jump though before getting anywhere.

Well, no more. Config problems with your web-app? Data needs to be converted to or from an obscure custom format? Need to understand why your code does not do what you think it should? Or understand someone else's code quickly? LLMs got you covered. It's like rubberducking but the duck talks back and can solve the entire problem for you!

Yes, they make mistakes and one may need to verify the results. But in may cases this is trivial, or not really necessary, for example when discussing different tools or solutions to a problem. Skimming through the alternatives quickly lets one choose a path forward that is very likely better than it would have been without asking the model.

This is an import aspect: having some taste and quick judgement helps a lot, in other words knowing what you want. If you really do, you probably are able to explain it well enough to an LLM and get it to execute for you. If not, then LLMs can help you too, but one needs to have enough clarity of mind to recognize this as a different mode of operation, where non-leading questions and iterations on the problem can improve one's thinking very much like a discussion with a collegue or expert would have done.

To quote TheZvi:

AI is the best tool ever invented for learning. AI is the best tool ever invented for not learning. You can choose which way you use AI. #1 is available but requires intention.

Tagged ,

Pycpl With Batteries Included

Last week, on a whim, I gave Claude Code (CC) a task that turned out to be both possible and highly useful, because it removed a common annoyance for some colleagues and myself.

See, there is this C-library called CPL that ESO uses for processing of astronomical data. There also is a Python-wrapper for it, pycpl, that allows to use the library from Python, which is great because it's the language that astronomers and data scientists mostly use nowadays.

However, pycpl does not come with CPL, but instead requires it to be installed beforehand, which often implies compiling it oneself because not all operating systems package the right version, if at all. This is not a big hurdle for developers, but if one wants to share a half-finished pipeline with some prospective users, it easily becomes one. Containers and such can help with this but are always a crutch that I would rather avoid.

Claude to the rescue. The off-handed remark in a telecon, that we should just make a pycpl package that comes with CPL (and its dependency libs) included, took hold with me long enough to ask CC to just do it!

I started by downloading the latest CPL source code, and the three libs it needs. Then I asked CC to initialize the git repository and sort out which files to add and which to ignore.

After pushing to Github, I could switch to the online version of CC where I had free credits to burn, so no harm done if this endeavour would turn into failure. Then I just quickly told it what to do like this, typos and all:

pycpl is a python wrapper for C-lib CPL. But it is packaged without the C-lib, so the overall goal is to upgrade the pycpl package to include the build of CPL and its depencencies (which are also present here). start by looking at the build system of pycpl and how to include the other lobraries to it. then move the libs to appropriate places inside pycpl and try the build.

This session log and this follow-up basically show how CC figured it all out. I only skimmed through it at the time and could not tell you what exactly it did. At some point I realized it needed some of the files that were omitted earlier, so I added those back. In the end, I had a package that installed locally -- a success already.

But what would make this really useful would be a Python "wheel", i.e. a package bundle that is pre-compiled for different platforms and Python version. This way, users would be able to install instantly, without any compiling happening at all. So I naturally asked CC about it, and how to set it up such that GitHub Actions do the compiling. This was the most tedious bit. CC needed many iterations to get this right and compiling on GitHub is not fast. So I let it work in the background over an evening, only checking in occasionally. Claude figured it out in the end! The package installs and works nicely for myself and several colleagues.

Initially, the plan was to also upload to PyPI, because ESO does not actually do that. But I was not able to put claim to the name "pycpl" there, and without that it would not work. Plus I did not want to step on people's toes too much by publishing work that is not my own. Even though, in principle, it should be fine with GPL-licensed code.

Thus, for now, one has to provide an "extra index URL" to install this pycpl package. Use uv, for example like this:

    (uv) pip install pycpl --extra-index-url https://ivh.github.io/pycpl/simple/

Or try if it works without having anything prepared:

    uv run --with pycpl --extra-index-url https://ivh.github.io/pycpl/simple/ python -c "import cpl;"

Or add it to the header of a script file like this:

    uv add --script main.py --index https://ivh.github.io/pycpl/simple/  pycpl

One can also add the index URL to one's pyproject.toml, together with ESO index URL that provides tools like pyesorex and edps, which seem to play nicely with my pycpl instead of ESO's own. For how to do that, see the README in the GitHub repo.

Tagged ,