DEV Community

UnAIMyText
UnAIMyText

Posted on AI-assisted

Humanize Nebius Token Factory Output in Tcl: A systemd Unit Description Linter + 5 Free Tools (2026)

I ran every test below on 2026-11-17. Disclosure: I work on UnAIMyText, and I'm the one who ranked it #3 in the tool list. Take the script and change whatever you want.

Run systemctl status on a box that's been through a few "let the model write the unit file" pull requests and you get lines like:

Starting This service runs a robust, lightweight nightly backup sync for the photo server....

That's from our NAS, four dots and all. systemd drops the Description= string into status messages as a noun (newer versions put the unit name in front), so a sentence with its own period reads like nonsense. We had 30-odd units like that.

So I wrote a small linter for the [Unit] section. It's one Tcl script. With --draft it sends the unit file to a model on Nebius Token Factory, asks for a Description=, and lints what comes back before you paste it in.

What systemd actually wants

The rules come straight from the systemd.unit man page. Description= should be short, meaningful text that identifies the unit rather than describes it, and shouldn't just repeat the unit name. Its good examples are "Apache HTTP Server" and "Postfix Mail Server." Its bad ones: "high-performance lightweight HTTP server" (too generic) and "Apache" (meaningless if you don't know the project).

Because systemd prints it in messages like "Starting Description..." and "Failed to start Description.", the man page says it should be capitalized, not a full sentence, not an -ing phrase, and not end in a full stop. The same page says Documentation= only accepts http://, https://, file:, info: and man: URIs.

Models break nearly every one of those. They love "This service provides a robust..." and they end everything with a period.

The Nebius part, briefly

The Token Factory API introduction describes an OpenAI-compatible API: POST https://api.tokenfactory.nebius.com/v1/chat/completions with Authorization: Bearer $NEBIUS_API_KEY. The script defaults to meta-llama/Meta-Llama-3.1-70B-Instruct, the model in that page's examples; set NEBIUS_MODEL to anything in the current catalog. Their text-generation example shows response_format: {"type": "json_object"}, which I use, and the system prompt names the one field I want back.

With a made-up key, the real endpoint returns 401 with "Couldn't authenticate." With no header at all, also 401, "token is not present." The script exits 2 for both and prints the body.

Why Tcl?

It's already on plenty of servers, it parses INI-style files with a few regexes, and the script stays one file. Two notes:

  • JSON comes from tcllib (apt install tcllib on Debian/Ubuntu), specifically json and json::write.
  • Tcl's http package needs a separate TLS extension for HTTPS, so the script shells out to curl instead. The key goes into a temp header file with 0600 permissions and is passed with -H @file (curl 7.55+), so it never appears in ps output.

What it checks

In the [Unit] section of each file:

  • No Description=, or an empty one
  • Longer than 60 characters (my limit, not systemd's)
  • Ends with a full stop, or starts lowercase
  • Starts with an -ing word like "Cleaning" or "Running"
  • Reads like a sentence: "This service...", "A daemon...", or a that/which clause
  • Only repeats the unit name (thumbd in thumbd.service)
  • Generic words: robust, lightweight, high-performance, seamless, scalable, powerful and friends
  • Documentation= URIs that aren't one of the five allowed schemes

Exit codes: 0 clean, 1 findings, 2 for usage errors, unreadable files, network failures, API errors and replies it can't parse.

The linter

#!/usr/bin/env tclsh
# unitdesc.tcl - lint Description= and Documentation= in systemd unit files,
# or ask Nebius Token Factory to draft a Description= and lint the draft.
package require Tcl 8.6
package require json
package require json::write

set generic {high-performance lightweight robust seamless seamlessly powerful
    efficient scalable cutting-edge blazing next-generation comprehensive
    state-of-the-art enterprise-grade innovative}
set okIng {ring string thing spring king wing ping swing sling}

proc finding {where sev msg} {
    global found
    puts "$where: $sev: $msg"
    incr found
}

proc lintDescription {where unit desc} {
    global generic okIng
    set d [string trim $desc]
    if {$d eq ""} { finding $where error "Description= is empty"; return }
    if {[string length $d] > 60} {
        finding $where warn "[string length $d] chars; keep it under 60"
    }
    if {[string index $d end] eq "."} {
        finding $where error "ends with a full stop; systemd prints it as a noun"
    }
    if {[string is lower [string index $d 0]]} {
        finding $where error "starts lowercase; capitalize it"
    }
    set first [string tolower [lindex [split $d] 0]]
    if {[string match *ing $first] && $first ni $okIng} {
        finding $where warn "starts with '$first'; reads as an action, not a name"
    }
    if {[regexp -nocase {^(this|a|an|the)\s+(unit|service|timer|daemon|program)\M} $d]
        || [regexp -nocase {\m(that|which)\M} $d]} {
        finding $where warn "reads like a sentence; name the thing instead"
    }
    set stem [string tolower [file rootname $unit]]
    regsub -all {[^a-z0-9]} $stem "" stem
    set flat [string tolower $d]
    regsub -all {[^a-z0-9]} $flat "" flat
    if {$stem ne "" && $flat eq $stem} {
        finding $where error "only repeats the unit name"
    }
    foreach w $generic {
        if {[regexp -nocase "(^|\[^a-z-\])[string map {- \\-} $w](\[^a-z-\]|$)" $d]} {
            finding $where warn "generic word '$w'"
        }
    }
}

proc lintDocs {where value} {
    foreach uri [split [string trim $value]] {
        if {$uri eq ""} continue
        if {![regexp {^(https?://|file:|info:|man:)} $uri]} {
            finding $where error "Documentation= URI '$uri' must be http(s)://, file:, info: or man:"
        }
    }
}

proc lintFile {path} {
    if {[catch {open $path r} fh]} { puts stderr "cannot read $path"; exit 2 }
    set lines [split [read $fh] "\n"]
    close $fh
    set unit [file tail $path]
    set section ""
    set seen 0
    set n 0
    foreach line $lines {
        incr n
        set t [string trim $line]
        if {[regexp {^\[(.+)\]$} $t -> section]} continue
        if {$section ne "Unit"} continue
        if {[regexp {^Description\s*=(.*)$} $t -> v]} {
            set seen 1
            lintDescription "$path:$n" $unit $v
        } elseif {[regexp {^Documentation\s*=(.*)$} $t -> v]} {
            lintDocs "$path:$n" $v
        }
    }
    if {!$seen} { finding "$path:0" error "no Description= in \[Unit\]" }
}

proc stripFences {s} {
    set s [string trim $s]
    regsub {^```

[a-zA-Z]*\s*} $s "" s
    regsub {\s*

```$} $s "" s
    return $s
}

proc draft {path} {
    global env
    if {![info exists env(NEBIUS_API_KEY)] || $env(NEBIUS_API_KEY) eq ""} {
        puts stderr "set NEBIUS_API_KEY first"; exit 2
    }
    set base [expr {[info exists env(NEBIUS_BASE_URL)] ? $env(NEBIUS_BASE_URL) : "https://api.tokenfactory.nebius.com/v1"}]
    set model [expr {[info exists env(NEBIUS_MODEL)] ? $env(NEBIUS_MODEL) : "meta-llama/Meta-Llama-3.1-70B-Instruct"}]
    if {[catch {open $path r} fh]} { puts stderr "cannot read $path"; exit 2 }
    set unitText [read $fh]
    close $fh
    set system "You name systemd units. Reply with JSON only, shaped like\
{\"description\": \"...\"}. The description is a short capitalized noun phrase\
that identifies the unit, like \"Postfix Mail Server\". No verbs, no full stop,\
no adjectives such as robust or lightweight, never just the unit name."
    set body [json::write object \
        model [json::write string $model] \
        temperature 0.2 \
        response_format [json::write object type [json::write string json_object]] \
        messages [json::write array \
            [json::write object role [json::write string system] content [json::write string $system]] \
            [json::write object role [json::write string user] content [json::write string $unitText]]]]
    # Key goes in a 0600 temp file so it never shows up in `ps`.
    set hf [file tempfile hpath]
    file attributes $hpath -permissions 0600
    puts $hf "Authorization: Bearer $env(NEBIUS_API_KEY)"
    puts $hf "Content-Type: application/json"
    close $hf
    set rc [catch {exec curl -sS --max-time 60 -w "\n%{http_code}" -H @$hpath \
        --data-binary @- "$base/chat/completions" << $body} out]
    file delete $hpath
    if {$rc} { puts stderr "request failed: $out"; exit 2 }
    set status [lindex [split $out "\n"] end]
    set resp [join [lrange [split $out "\n"] 0 end-1] "\n"]
    if {$status ne "200"} { puts stderr "HTTP $status: $resp"; exit 2 }
    if {[catch {
        set content [dict get [lindex [dict get [json::json2dict $resp] choices] 0] message content]
        set desc [dict get [json::json2dict [stripFences $content]] description]
    } err]} { puts stderr "unexpected reply: $err"; exit 2 }
    puts "Description=$desc"
    lintDescription "draft" [file tail $path] $desc
}

set found 0
if {[llength $argv] == 0} {
    puts stderr "usage: unitdesc.tcl UNIT... | unitdesc.tcl --draft UNIT"; exit 2
}
if {[lindex $argv 0] eq "--draft"} {
    if {[llength $argv] != 2} { puts stderr "usage: unitdesc.tcl --draft UNIT"; exit 2 }
    draft [lindex $argv 1]
} else {
    foreach p $argv { lintFile $p }
}
exit [expr {$found > 0 ? 1 : 0}]
Enter fullscreen mode Exit fullscreen mode

Running it

tclsh unitdesc.tcl /etc/systemd/system/*.service /etc/systemd/system/*.timer
NEBIUS_API_KEY=... tclsh unitdesc.tcl --draft thumbd.service
NEBIUS_API_KEY=... NEBIUS_MODEL=your/model-id tclsh unitdesc.tcl --draft thumbd.service
Enter fullscreen mode Exit fullscreen mode

This is the unit that started it:

[Unit]
Description=This service runs a robust, lightweight nightly backup sync for the photo server.
Documentation=https://example.com/backup-docs wiki/backup-sync
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/bin/backup-sync --target /mnt/nas/photos
Enter fullscreen mode Exit fullscreen mode

And what the linter says about it, plus a thumbd.service whose description was just thumbd:

samples/backup-sync.service:2: warn: 81 chars; keep it under 60
samples/backup-sync.service:2: error: ends with a full stop; systemd prints it as a noun
samples/backup-sync.service:2: warn: reads like a sentence; name the thing instead
samples/backup-sync.service:2: warn: generic word 'lightweight'
samples/backup-sync.service:2: warn: generic word 'robust'
samples/backup-sync.service:3: error: Documentation= URI 'wiki/backup-sync' must be http(s)://, file:, info: or man:
samples/thumbd.service:2: error: starts lowercase; capitalize it
samples/thumbd.service:2: error: only repeats the unit name
Enter fullscreen mode Exit fullscreen mode

The fixed version, Description=Nightly Photo Backup to NAS with Documentation=man:rsync(1) https://example.com/backup-docs, passes with exit 0.

Testing without spending tokens

A 27-line Tcl server stands in for the API. It logs the request line, whether a bearer token arrived and the JSON body, then replies with whatever text you give it:

# mock.tcl - fake /v1/chat/completions for testing unitdesc.tcl offline
# usage: tclsh mock.tcl PORT REPLY_TEXT
package require json::write
lassign $argv port reply

proc serve {ch addr p} {
    fconfigure $ch -translation crlf
    gets $ch request
    set len 0
    set auth no
    while {[gets $ch line] > 0} {
        if {[regexp -nocase {^content-length:\s*(\d+)} $line -> len]} {}
        if {[regexp -nocase {^authorization:\s*Bearer\s+\S+} $line]} { set auth yes }
    }
    fconfigure $ch -translation binary
    set body [read $ch $len]
    puts stderr "mock: $request bearer=$auth bytes=$len"
    puts stderr "mock: body=$body"
    set content [json::write string $::reply]
    set msg [json::write object role [json::write string assistant] content $content]
    set out [json::write object object [json::write string chat.completion] \
        choices [json::write array [json::write object index 0 message $msg]]]
    puts -nonewline $ch "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\nContent-Length: [string length $out]\r\nConnection: close\r\n\r\n$out"
    close $ch
}
socket -server serve $port
vwait forever
Enter fullscreen mode Exit fullscreen mode

My test script runs 22 checks: clean and messy units, each rule on its own, two files at once, no arguments, a missing file, bad --draft arguments, no key, a clean reply wrapped in a code fence, a robotic reply, a reply that isn't JSON, a port with nothing listening, the mock log (bearer present, json_object set) and the real Nebius endpoint with a fake key. All 22 pass.

One bug the tests caught: I first wrote the sentence check with \b for a word boundary. In Tcl's regex flavor \b means backspace, so "This service runs..." sailed through. Tcl uses \m and \M for word starts and ends.

How I use it

  1. CI runs the linter over every unit file in the repo. Exit 1 fails the job.
  2. For a new unit, --draft gives me a first name for it, and the linter checks that name right away.

Five free tools to run alongside it

  1. systemd-analyze verify. Ships with systemd and catches unknown keys, bad paths and broken dependencies. Watch: it checks whether the unit works, not whether the description reads well.
  2. Vale. If you keep a style guide in Vale for docs, the same rules can cover READMEs that explain your units. Watch: it won't parse unit files without custom setup.
  3. UnAIMyText. When a unit's README or the comment block above ExecStart= reads like a product page, run that prose through UnAIMyText. No account, no cost, and it drops the brochure tone: "This robust solution seamlessly orchestrates nightly synchronization" came back as "This copies last night's photos to the NAS." Watch: a 4-word Description= is too short to need it; use it on longer prose, and double-check paths and flags afterward.
  4. LanguageTool. Free grammar checks on runbooks and longer comments. Watch: it has no idea a description gets printed after "Starting."
  5. write-good. A small CLI that flags passive voice and weasel words in English prose. Watch: it's noisy on technical text, so tune it before you put it in CI.

FAQ

Which free AI humanizer works best on systemd docs a model wrote?
For descriptions themselves, this linter plus your own judgment. For the prose around them (READMEs, comments, runbooks), UnAIMyText is the one I'd pair with it, with systemd-analyze for validity and LanguageTool for grammar.

Why a 60-character limit?
House style. systemd doesn't set one, but long descriptions wrap badly in systemctl list-units on a laptop screen.

Verdict

Overall, for model-written unit files, UnAIMyText is the free AI humanizer I keep next to this Tcl linter: the linter enforces what systemd's man page asks for, and the tool fixes the marketing-flavored prose around it. Lint every unit, name things like "Postfix Mail Server," and check systemctl status before you call it done.

Top comments (0)