How the ngpt Rewrite Mode Functions with the --humanize Flag to Transform AI-Generated Text
When you apply the --humanize flag to ngpt's rewrite mode, the tool switches from standard readability improvements to a specialized system prompt that strips AI-detection markers and injects natural human writing patterns.
The nazdridoy/ngpt repository provides a powerful CLI for interacting with large language models, including a dedicated rewrite mode for text transformation. When you need to transform AI-generated text into content that reads as authentically human-written, the rewrite mode functions with the --humanize flag to modify its underlying behavior. This article examines the source code implementation to explain exactly how this transformation occurs.
What Is the --humanize Flag in ngpt Rewrite Mode?
The --humanize flag is a boolean CLI argument that alters the rewrite mode's objective from general text improvement to AI-to-human style conversion. Instead of simply enhancing readability, the system instructs the LLM to remove formulaic AI patterns, vary sentence structures, and introduce natural imperfections that characterize human writing.
How the Rewrite Mode Switches to Humanize Mode
The transformation involves three critical switching points in the codebase: argument parsing, system prompt selection, and user interface adaptation.
CLI Argument Detection in args.py
The flag is defined in ngpt/cli/args.py at lines 13-15 using argparse:
# In ngpt/cli/args.py
parser.add_argument(
'--humanize',
action='store_true',
help='Humanize AI-generated text to bypass AI detection'
)
When present, this sets args.humanize to True, which propagates through the application.
System Prompt Selection in rewrite.py
The core logic resides in ngpt/cli/modes/rewrite.py. At lines 63-66, the code selects between two distinct system prompts based on the flag:
# In ngpt/cli/modes/rewrite.py
base_system_prompt = (
HUMANIZE_SYSTEM_PROMPT
if getattr(args, 'humanize', False)
else REWRITE_SYSTEM_PROMPT
)
The HUMANIZE_SYSTEM_PROMPT (defined around lines 74-156) specifically instructs the LLM to "transform AI-generated text into human-like content that passes AI detection tools," while REWRITE_SYSTEM_PROMPT (lines 10-44) focuses on general readability improvements.
UI Adaptations for Humanize Mode
The user interface updates dynamically based on the flag. At lines 172-179 in rewrite.py, the input prompt changes:
# Input prompt adaptation
if getattr(args, 'humanize', False):
print_colored("Enter or paste AI-generated text to humanize...", "cyan")
else:
print_colored("Enter or paste text to rewrite...", "cyan")
Additionally, the operation spinner label updates at lines 177-181:
operation_text = (
"Humanizing AI text..."
if getattr(args, 'humanize', False)
else "Rewriting text..."
)
Practical Examples of Using --humanize
Here are concrete implementations demonstrating how the rewrite mode functions with the --humanize flag.
Basic Humanization of AI Text
Transform generic AI output into natural human prose:
ngpt --rewrite --humanize "Artificial intelligence is revolutionizing the healthcare industry by enhancing diagnostic accuracy, streamlining administrative processes, and improving patient outcomes."
The system sends the HUMANIZE_SYSTEM_PROMPT to the LLM, resulting in text that removes formulaic patterns and introduces natural variations.
Piping AI-Generated Content
Process content from other AI tools directly:
echo "The implementation of the feature, which was delayed due to unforeseen technical complications, is now scheduled for next week's release." | ngpt --rewrite --humanize
This demonstrates how the rewrite mode functions with piped input when the --humanize flag is applied, maintaining the same prompt selection logic.
Combining with Custom Pre-prompts
Layer additional instructions atop the humanize base prompt:
ngpt --rewrite --humanize --preprompt "Use a conversational tone suitable for a tech-blog audience."
The code prepends your custom pre-prompt to HUMANIZE_SYSTEM_PROMPT, allowing fine-grained control while maintaining the AI-detection bypass instructions.
Summary
- The
--humanizeflag innazdridoy/ngptswitches rewrite mode from general text improvement to AI-to-human style conversion. - The flag is defined in
ngpt/cli/args.pyand checked viagetattr(args, 'humanize', False)throughout the codebase. - When active, the system substitutes
HUMANIZE_SYSTEM_PROMPTforREWRITE_SYSTEM_PROMPTinngpt/cli/modes/rewrite.py, explicitly instructing the LLM to remove AI-detection markers. - UI elements including input prompts and spinner labels dynamically update to reflect the humanization operation.
- The feature works with stdin, piped input, file redirection, and combines seamlessly with
--prepromptand other CLI flags.
Frequently Asked Questions
What is the difference between standard rewrite mode and humanize mode?
Standard rewrite mode uses REWRITE_SYSTEM_PROMPT to improve readability and flow while preserving the original tone and structure. Humanize mode activates when you apply the --humanize flag, switching to HUMANIZE_SYSTEM_PROMPT which specifically targets AI-detection markers, formulaic sentence structures, and robotic phrasing to produce text that mimics authentic human writing patterns.
Can I use --humanize with other ngpt flags?
Yes, the --humanize flag functions seamlessly with other CLI options. You can combine it with --preprompt to layer custom instructions atop the humanize system prompt, use it with --temperature to control creativity levels, or pipe input via stdin. The flag only affects the system prompt selection and UI labels in ngpt/cli/modes/rewrite.py, leaving other functionality unchanged.
Where are the system prompts defined in the source code?
The system prompts are defined in ngpt/cli/modes/rewrite.py. REWRITE_SYSTEM_PROMPT appears around lines 10-44 and contains instructions for general text improvement. HUMANIZE_SYSTEM_PROMPT is defined around lines 74-156 and includes specific directives to bypass AI detection tools by introducing natural human writing quirks. The selection logic at lines 63-66 determines which prompt the LLM receives based on the --humanize flag state.
Does humanize mode work with piped input?
Yes, humanize mode fully supports piped input and stdin redirection. When you pipe text into ngpt --rewrite --humanize, the code in rewrite_mode detects the input stream, applies the HUMANIZE_SYSTEM_PROMPT, and processes the content exactly as it would with interactive input. This makes it ideal for integrating into automated workflows where AI-generated content from other tools needs immediate humanization before publication.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →