
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@johnlindquist/file-forge
Advanced tools
File Forge is a powerful CLI tool for deep analysis of codebases, generating markdown reports to feed AI reasoning models.
File Forge is a powerful command‑line tool for deep analysis of codebases. It scans your project (or GitHub repository) and generates comprehensive markdown reports that include a summary, a visual directory structure, file contents, and even dependency graphs. These reports are designed to feed AI reasoning models and support a variety of advanced use cases.
Note: File Forge works both with GitHub URLs (by cloning/updating a cached repository) and local directories. It also supports filtering files by patterns, searching for specific content, and advanced output options like piping, clipboard copy, and XML wrapping.
--include
and --exclude
to select exactly which files to analyze.--find
(OR behavior) or require specific strings in file content using --require
(AND behavior).--branch
) or commits (--commit
) for GitHub-hosted repositories.--graph
flag.--pipe
--open
--clipboard
--markdown
(default output is XML)--whitespace
--dry-run
/ -D
--bulk
--debug
or --verbose
--template
--allow-large
to override this check for very large codebases.ffg.config.jsonc
.Install File Forge globally with your favorite package manager:
# Using pnpm:
pnpm add -g @johnlindquist/file-forge
# Or using npm:
npm install -g @johnlindquist/file-forge
# Analyze all files in current directory
ffg
# Analyze specific directory/files in current directory
ffg src
ffg "src/**/*.ts"
ffg https://github.com/owner/repo --branch develop
ffg /path/to/local/project
Use glob patterns to precisely control which files are included or excluded.
# Include only TypeScript files in the root of the current directory
ffg --include "*.ts"
# Include TypeScript files recursively in all subdirectories
ffg --include "**/*.ts"
# Exclude node_modules and test files recursively
ffg --exclude "**/*test.*,node_modules/**"
# Combine include and exclude for specific filtering in the 'src' directory
ffg src --include "**/*.ts" --exclude "**/*.spec.ts,**/__tests__/**"
Note:
*.ts
matches files only in the immediate directory being scanned.**/*
to match files recursively through all subdirectories (e.g., **/*.ts
)."*.ts,*.js"
) or by using multiple --include
/ --exclude
flags (e.g., --include "*.ts" --include "*.js"
).ffg --include "**/*.ts,/Users/me/Documents/important_config.json"
).ffg src --find "console,debug"
ffg src --require "console,log"
ffg --graph src/index.js
ffg src --pipe
ffg src --clipboard
ffg src --markdown
ffg src --whitespace
ffg src --dry-run
# Alias
ffg src -D
ffg /path/to/very/large/project --allow-large
ffg src --bulk
ffg src --debug
ffg src --verbose
<project>
<source>/path/to/source</source>
<timestamp>20240324-123456</timestamp>
<command>ffg src --verbose</command>
</project>
# List all available templates
ffg --list-templates
# Apply a specific template
ffg src --template refactor
# Combine with other options
ffg src --template test --include "*.js" --exclude "*.test.js"
ffg.config.jsonc
)File Forge supports a configuration file named ffg.config.jsonc
(or ffg.config.json
) in the root of your project (the directory where you run ffg
). This allows you to define default options and create reusable, named command configurations.
Features:
defaultCommand
object whose flags will be applied automatically whenever ffg
is run without the --use
flag.commands
object. Invoke a specific named command using the --use <command-name>
flag.ffg.config.jsonc
file for better documentation.--use <name>
, the named command's settings override defaultCommand
settings.--include
, --exclude
, --find
, --require
, and --extension
, values provided on the command line are merged with (added to) the values defined in the applied configuration (either defaultCommand
or the named command used with --use
).--save
/ --save-as
): You can easily save the current set of command-line flags to your ffg.config.jsonc
file:
--save
: Saves the current flags (excluding transient flags like --pipe
, --debug
, etc.) as the new defaultCommand
, overwriting any existing default.--save-as <name>
: Saves the current flags under a new named command (or overwrites an existing one with the same name) in the commands
section.Example ffg.config.jsonc
:
{
// Default settings applied when no --use flag is given
"defaultCommand": {
"exclude": ["node_modules/**", "dist/**", "*.log"],
"ignore": true, // Respect .gitignore by default
"skipArtifacts": true
},
// Reusable named command configurations
"commands": {
"ts-analysis": {
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts", "**/*.spec.ts"], // Merged with defaultCommand exclude on use
"require": ["import", "export"],
"verbose": true
},
"docs-only": {
"include": ["**/*.md", "docs/**"],
"markdown": true
},
"find-todos": {
// Inherits defaults from defaultCommand if not overridden
"find": ["TODO", "FIXME"],
"include": ["src/**", "scripts/**"]
}
}
}
Usage with Config:
# Uses defaultCommand settings (exclude node_modules, etc.)
ffg .
# Uses the 'ts-analysis' named command settings
ffg --use ts-analysis
# Uses 'ts-analysis' but overrides verbose and adds another include pattern
ffg --use ts-analysis --verbose=false --include "tests/**/*.ts"
# Resulting flags: include=["src/**/*.ts", "tests/**/*.ts"], exclude=[...], require=[...], verbose=false
# Uses 'find-todos' command
ffg --use find-todos
# Save current flags as the new default command
ffg . --include "**/*.ts" --exclude "node_modules/**" --verbose --save
# This will update ffg.config.jsonc's "defaultCommand"
# Save current flags as a named command 'test-setup'
ffg . --require "test" --exclude "dist/**" --save-as test-setup
# This will add or overwrite "test-setup" in ffg.config.jsonc's "commands"
File Forge includes a set of prompt templates that can be applied to your analysis results. These templates are designed to guide AI models (like GPT-4 or Claude) in performing specific tasks on your code.
Documentation & Explanation
explain
: Summarize what a code file does in plain languagedocument
: Insert explanatory comments into the codeRefactoring & Improvement
refactor
: Improve code clarity and maintainability without changing behavioroptimize
: Improve code efficiency without changing behaviorfix
: Find potential bugs or issues and fix themCode Generation
test
: Generate unit tests for the given codeList all available templates:
ffg --list-templates
Apply a template to your analysis:
ffg src --template refactor
The template will be included in the output, with your code analysis inserted in the appropriate place.
When you view the output in an editor or copy it to the clipboard, you can then paste it to an AI assistant to get the desired result.
You can create your own templates or override the built-in ones by creating individual template files in your File Forge configuration directory:
~/Library/Preferences/@johnlindquist/file-forge/templates/
~/.config/@johnlindquist/file-forge/templates/
%APPDATA%/@johnlindquist/file-forge/templates/
Each template is a Markdown (.md
) file with front-matter containing metadata and a body containing the template content. Here's an example template custom-explain.md
:
---
name: custom-explain
category: documentation
description: My custom explanation template
---
**Goal:** Explain this code in simple terms.
**Context:**
{{ code }}
<instructions>
- Explain what this code does in simple language
- Focus on the main functionality
</instructions>
<task>
Provide a clear explanation of the code for a non-technical audience.
</task>
When you run File Forge, it will automatically load and merge your custom templates with the built-in ones.
For a complete list of options and examples, run:
ffg --help
Analysis results and configuration are stored in:
~/Library/Preferences/@johnlindquist/file-forge/config/
~/.config/@johnlindquist/file-forge/config/
%APPDATA%/@johnlindquist/file-forge/config/
To contribute or run File Forge locally:
git clone https://github.com/johnlindquist/file-forge.git
cd @johnlindquist/file-forge
pnpm install
pnpm build
This project is licensed under the MIT License – see the LICENSE file for details.
The test suite has been optimized to run faster using several strategies:
Tests can now run concurrently, leveraging multiple CPU cores for faster test execution. This is enabled in vitest.config.ts
by removing the sequence: { concurrent: false }
option.
Instead of spawning a new process for each test (which is slow), many tests now use the direct function testing approach through utils/directTestRunner.ts
. This utility allows tests to call the main application functions directly while capturing their output.
Benefits:
To migrate an existing test to use direct function testing:
Run the test analysis to see candidates for optimization:
pnpm test:optimize:analyze
Migrate a specific test file:
pnpm test:optimize test/your-test-file.test.ts
Verify the test still passes and check the performance improvement.
To optimize multiple tests at once, you can use the batch processing options:
Analyze and run a dry-run batch (no changes applied):
pnpm test:optimize:batch:dry
Fast batch migration (skips performance measurement):
pnpm test:optimize:batch:fast
Full batch migration with performance measurements:
pnpm test:optimize:batch
Additional options:
--force
to re-optimize already migrated files--dry-run
to see what would be changed without making actual changes--skip-measure
to skip performance measurements (faster)beforeAll
instead of beforeEach
when the setup only needs to be done once for all tests in a describe blockwaitForFile
helper with appropriate timeouts for file-based testspnpm test:direct
to verify they still workscripts/optimize-tests.js
: Helper script to analyze and optimize test filesutils/directTestRunner.ts
: Direct function execution utilitytest/helpers/fileWaiter.ts
: Optimized file waiting utility with adaptive pollingFAQs
File Forge is a powerful CLI tool for deep analysis of codebases, generating markdown reports to feed AI reasoning models.
The npm package @johnlindquist/file-forge receives a total of 3 weekly downloads. As such, @johnlindquist/file-forge popularity was classified as not popular.
We found that @johnlindquist/file-forge demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.